unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Filipp Gunbin <fgunbin@fastmail.fm>
To: emacs-devel@gnu.org
Subject: Git workflow
Date: Fri, 10 Apr 2015 01:34:23 +0300	[thread overview]
Message-ID: <m2wq1lylqo.fsf@fastmail.fm> (raw)

A lot of things have been said on this list about git recently.

Here I want to just make some points which make my life with git easy.

Sorry for noise if you all know this or use different workflows.

- I start working on brances by creating them with

`git checkout -b <name> origin/<remote_name>'

<remote_name> is usually "master"

This way a later `git rebase' will put commits in the current branch on
top of <remote_name>.

- Review my changes with `vc-dir' (`C-x v d') and diffing from there
  with `='.

- Commit periodically (every day for a long task) all changes with

`git commit -am "message"'

- Push periodically (usually right after commit) with

`git push origin <name>',

where <name> is my current branch

This is just not to lose changes if I lose my computer.

- Then, when it's time to send code for review, I look up in the root vc
  log (`C-x v L') the hashtag of the commit just before my first commit
  and copy it.  This is needed for interactive rebase which I do to
  squash all intermediate commits into one:

- open term-mode and run `EDITOR='emacs --no-desktop' git rebase -i
  <commit>'

Yes, emacs inside emacs!  Leave first string as "pick" and change all
other from "pick" to "fixup".  Save, exit.  Git squashes commits into
one.

- If there is a need to fix commit message, do this:

`git commit -am "New message" --amend'

- Then, it's time to rebase:

`git fetch && git rebase'

A branch is "remote-tracking" so it knows on top of which remote branch
it is, and rebase functionality uses that knowledge.  What happens is
that git fetches all new commits (on all branches) from remote, then
checks out <remote_name> and applies my commits from the current branch
on top of it.

- If I have conflicts at this point, go and resolve them: edit files
  containing conflict markers (I remember somewhere in vc exists the
  command to go through them one by one, but it didn't work for me),
  then `git add' on each file after editing.

- After all conflicts are resolved:

`git rebase --continue'

Squashing commits into one helps to do this resolve-continue procedure
only once, otherwise rebase would stop after each conflicting commit.

- Now we are ready for push:

`git push origin <name>'

- As review goes I make changes just as before, when working on initial
  version.

- When I'm done and have a final commit, I do the most important push:

`git push origin <name>:<remote_name>'

So all my changes go to the remote branch as a single commit.

- Very-very rarely I have to merge something (when it's really a
parallel branch and not a catchup with "parent" remote branch), then I
use merge without any clever options.

- If something goes wrong I just make text patch when on a branch (`D'
  in *vc-change-log*), create a new branch from scratch and apply the
  patch with `patch' command.

Filipp



             reply	other threads:[~2015-04-09 22:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-09 22:34 Filipp Gunbin [this message]
2015-04-10  6:49 ` Git workflow Andreas Schwab
2015-04-10  9:48   ` Filipp Gunbin
2015-04-10 10:19     ` Lars Brinkhoff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2wq1lylqo.fsf@fastmail.fm \
    --to=fgunbin@fastmail.fm \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).