Nice answer to the old question of an ‘svn -u status’ equivalent in git

Posted in: Bailey's Blog- Apr 10, 2012 No Comments

Thought I’d post this up as it’s the best answer I’ve found for the git equivalent of ‘svn -u status’

http://stackoverflow.com/questions/1138990/git-equivalent-of-svn-status-u

There is an excellent explanation of git principles at:

http://longair.net/blog/2009/04/16/git-fetch-and-merge/

Basically – what I do is:

git fetch

This will pull down any new commits which have been uploaded by others to the repository and point my local pointer

origin/branchname

to that commit.

Then I can call:

git diff branchname origin/branchname

which shows a diff between my current version of a branch and the current version of that branch from the repository.

When I want to merge in the changes from upstream to my local copy I make sure I’m on (i.e. have checked out) the branchname branch and call:

git merge origin/branchname

which merges in the the current remote repository version (which has been brought down by ‘git fetch’ to my local remote tracking branch origin/branchname)) – into the currently checked out branch called ‘mybranch’.

 

Git can be conceptually difficult – but this may explain things…

Local branches are local – fair enough.  ’Remote’ branches (origin/branchname etc) are your local copies of any code which is in the repository.  They can be behind your local branch (which is normal is you’ve updated code locally) or ahead of your local branch version (if you’ve used git fetch to pull down remote versions).

‘git fetch’ works primarily on remote branches.

Certain git commands – like ‘git pull’, ‘git checkout –track -b refactored origin/refactored’ work on local and remote branches at the same time and may tie them together.

HTH!

No Responses to “Nice answer to the old question of an ‘svn -u status’ equivalent in git”

Leave a Reply