I have a git repository that contains two branches, 1.0 and master. If I want to work on 1.0 I clone it using the following command:
git clone ssh://user@server/project -b 1.0 project-1.0
And all is well. If I issue a git branch command I see:
1.0
git branch -a looks like this:
* 1.0
remotes/origin/1.0
remotes/origin/HEAD -> origin/master
remotes/origin/master
However, if someone else pushes changes to master and I make changes to 1.0 and attempt to push, it will fail because I need to update my repo with the master changes. To do this I checkout master, pull the changes and then switch back to 1.0:
git checkout master
git pull
git checkout 1.0
However, is there a simpler way I can pull the latest changes without having to checkout master first?
According to your
git branch -a, you don’t have a local branch namedmaster. Thus,git log mastershould not work. A remote tracking branch — namely,origin/master— is always updated when you fetch. So if you want to see the log of themasterbranch from theoriginremote, all you have to do isgit fetch; git log origin/master. It sounds like you do not want to have your own version of master, thusgit checkout mastermay have been a mistake which is just confounding your workflow.This isn’t true. As long as no one has pushed divergent changes to 1.0, you can push to it. There’s nothing special about the master branch. You could use
git branch -d master(which, if it has diverged from 1.0, will notify you that it has been merged toorigin/masterbut not HEAD), since it seems like you’re not interested in maintaining your own version of master.Again, someone pushing to master does not stop you from pushing to 1.0, and you do not need to checkout a local
mastersimply to inspectorigin/master.