...
Also a quick tutorial on Git for SVN users. Eclipse users could have a look at Git version control with Eclipse (EGit) - Tutorial.
Comparison with subversion commands
We first list a subversion command, and after that the equivalent git command.
One of the most important difference from a user point of view is that since there is always one local repository and one or several remote repositories, there is a distinction in git between saving some work only locally on a private computer and making it available to other people who see only public remote computers. The first action is called commit, and it is therefore completely different from a subversion commit. The second action is called push. The equivalent to svn commit is therefore a pair of two commands, git commit followed by git push. It is possible to perform several git commits without doing any git push, which is impossible to do with subversion. Note that most commands (including log
and status
) only work on the local copy of a remote repository. You should therefore use git fetch
regularly to refresh your copy (if you do not want to pull
).
We first list a subversion command, and after that the equivalent git command (we use Apache Commons Math git repository as an example, of course you should adapt it depending on the project).
- {{svn checkout }}repo-url
git clone https://apacheID@git-wip-us.apache.org/repos/asf/commons-math.git
(read/write access, where apacheID is committer ID)
git clone https://git-wip-us.apache.org/repos/asf/commons-math.git
(read-only access) svn diff
git diff
(shows only unstaged changes,git diff --cached
shows prepared commit)svn add
svn add
– used to stage for commitsvn update
git pull
svn commit
git commit
, followed bygit push
. You need to stage (akaadd
all files which should be commited)svn status
(optionally refresh local stategit fetch
then)git status
- {{svn revert }}path
{{git checkout -- }}path svn info
git remote -v
andgit remote origin