It seems you want to keep your master
branch up to date so that you can do this later:
$ git checkout master
$ git merge A
But you don't need to strictly keep your master
branch up to date till the time you're finished with A
, since the origin/master
remote-tracking branch will be kept up to date when you do a fetch(this'll keep the branch A
unaffected, since the fetch will only get changes from the remote repository not change local branches at all.). In fact, this is the very purpose of a remote tracking branch.
Then when you are ready to merge your branch A
into master
, then you can do a merge on your master
branch(which git pull does automatically - it's just a fetch followed by a merge):
$ git checkout master
$ git fetch
$ git merge FETCH_HEAD
FETCH_HEAD
is updated by git fetch
and used by the git merge
command to store the commit which it wants to merge to - when you do a git pull
, this is the latest commit which is merged into your local branch.
From the git-merge
docs:
If no commit is given from the command line, merge the remote-tracking branches that the current branch is configured to use as its
upstream. See also the configuration section of this manual page.
When FETCH_HEAD
(and no other commit) is specified, the branches recorded in the .git/FETCH_HEAD
file by the previous invocation of git fetch
for merging are merged to the current branch.