git merge sanity check

Developer A is working on branch 2012A

I branch 2012A, and create branch 2012B

I want all the new changes from 2012A, so I simply want to merge them into 2012B and carry on working.

Does this look ok as a workflow?

git checkout 2012A (switch to 2012A)
git pull origin 2012A (update 2012A)
git checkout 2012B (switch to 2012B)

git merge 2012A (merge in 2012A)
git commit -m 'commiting changes from 2012A' (commit changes from 2012A in 2012B)

Thanks in advance,

  • How to abandon (switch from) a branch that requires merging?
  • How to remove commits from one git branch that have been merged into another
  • Undo a Git merge, but keep later changes, and rewrite history
  • git merge going wrong?
  • git pull merges no files if any of the deltas are conflicted (need manual merge)
  • Git deattached HEAD using synchronizing from GitHub client
  • How to rebase after a merge?
  • Git: get $REMOTE, $BASE and $LOCAL files when fixing merge conflicts
  • One Solution collect form web for “git merge sanity check”

    It should work, however you could do it in a simpler way:

    directly from branch 2012B:

    git fetch origin
    git merge origin/2012A

    Note that you are not required to have a local branch for 2012A: if have a repository in your remotes (here your remote is origin) you usually carry the snapshots of the remote branches. You can see them by running:

    git branch -a

    (See the remotes/... entries of the output)

    The git fetch command updates the snapshots, so git fetch origin updates your local images of the remote branches in origin, and git merge origin/2012A merges such image into the current branch (i.e. applies the patches of origin/2012A on 2012B).

    Suggested article:

    Git Baby is a git and github fan, let's start git clone.