What are the Git commands to do the following workflow?
Scenario
I cloned from a repository and did some commits of my own to my local reposit
git remote update && git status
Found this on the answer to Check if pull needed in Git
git remote update
to bring your remote refs up to date. Then you can do one of several things, such as:
git status -uno
will tell you whether the branch you are tracking is ahead, behind or has diverged. If it says nothing, the local and remote are the same.
git show-branch *master
will show you the commits in all of the branches whose names end in master (eg master and origin/master).If you use
-v
withgit remote update
you can see which branches got updated, so you don't really need any further commands.
git status
does not always show the difference between master and origin/master even after a fetch.
If you want the combination git fetch origin && git status
to work, you need to specify the tracking information between the local branch and origin:
# git branch --set-upstream-to=origin/<branch> <branch>
For the master branch:
git branch --set-upstream-to=origin/master master