- Before you start
- implemented in git 1.6.3 and higher
- git equivalents of the SVN commands
- NOTE: If you already have any clone of the repository, use git clone --reference [[ssh://[username@]git.freedesktop.org/git/ooo-build/ooo-build
- for committed, but not yet pushed changes see What if I committed something wrong in GettingIt
- Example git session
- it is our first session, we have to clone the repository
- develop something, now commit it
- continue developing, and commit it
- it is finished, patches apply, everything builds, let's check that we did not
- forget uncommitted changes
- looks fine, let's double check the diff
- everything is perfect, let's push to the remote repository
- oh, it failed! - somebody committed some changes in the meantime, let's update
- double check
- everything is fine
- More info
Before you do any git work, please don't forget to setup your name and email: [[!format txt """ git config --global user.email "firstname.lastname@example.org" git config --global user.name "Your Name" git config --global user.signingkey "0xKEY-ID" """]] If you want to setup these settings only for the ooo-build repository, you can omit the --global.
We also recommend the following settings: [[!format txt """
git config --global push.default tracking """]]
Please note that the git workflow is not completely 1:1 to SVN workflow thanks to the fact that the commits happen locally, and you have to additionally push the changes to the remote repository so that the changes are visible there - that's why I add git push in the table below everywhere it is necessary in order the changes appear in the remote repository.
Generally though, it is usually better not to hurry with pushing the changes, and check eg. git log -p before you do that.
|What||How you used to do it in SVN||How you do it now in git|
|Getting the repository (anonymous)||svn checkout http://.../trunk ooo-build||git clone git://anongit.freedesktop.org/git/ooo-build/ooo-build|
|Getting the repository||svn checkout svn+ssh://.../trunk ooo-build||git clone [[ssh://[username@]git.freedesktop.org/git/ooo-build/ooo-build||ssh://[username@]git.freedesktop.org/git/ooo-build/ooo-build]]|
|Getting a fresh branch||svn checkout svn+ssh://.../branches/ooo-build-3-0-1||git clone [[ssh://[username@]git.freedesktop.org/git/ooo-build/ooo-build||ssh://[username@]git.freedesktop.org/git/ooo-build/ooo-build]] ooo-build-3-0-1|
|git checkout -t origin/ooo-build-3-0-1|
|git branch -D master|
|ssh://[username@]git.freedesktop.org/git/ooo-build/ooo-build]] to save bandwidth.|
|Switching the repository to a branch||svn switch svn+ssh://.../branches/ooo-build-3-0-1||git checkout ooo-build-3-0-1|
|Getting new changes||svn up||git pull -r|
|Committing & publishing the changes||svn commit||git commit -a ; git push|
|Adding files||svn add file1 file2 ; svn commit||git add file1 file2 ; git commit ; git push|
|Removing files||svn rm file1 file2 ; svn commit||git rm file1 file2 ; git commit ; git push|
|Moving files||svn mv source dest ; svn commit||git mv source dest ; git commit ; git push|
|Copying files||svn cp source dest ; svn commit||cp source dest ; git add dest ; git commit ; git push|
|Checking history of changes||less ChangeLog (or svn log||less)||git log|
|Checking status||svn status||git status|
|Differences||svn diff||git diff|
|Tagging a release|| svn cp svn+ssh://.../trunk svn+ssh://.../tags/
|| git tag -s
|Reverting uncommitted changes||svn revert||git checkout -f # everything|
|git checkout file1 file2 fileN # just the selected files|
for committed, but not yet pushed changes see What if I committed something wrong in GettingIt
No ChangeLog is necessary in the git tree, it would just duplicate the information that you already have locally anyway. Due to that, please be careful and provide nice commit messages, like: [[!format txt """ First line roughly describing the change.
Leave one empty line, and then follow with more detailed description what and why you changed. It is really important to provide a good description on the first line, because some of the git tools (like gitk, git log --pretty=oneline, git rebase --interactive, etc.) show just the first line. Also we don't have a ChangeLog any more, so git log is now your source of the information about the changes.
Please do not forget to mention the bugzilla numbers, like i#12345 or bnc#234567.
- file1: Did this and that.
- file2: And something else here. """]] The commit hooks that get installed when you do ./autogen.sh should help you to create good commit messages.
[[!format txt """
git clone ssh://[username@]git.freedesktop.org/git/ooo-build/ooo-build
git commit -a
git commit -a
git log -p
git pull -r
git log -p
git push """]]