git is a distributed version control system originally written by Linus Torvalds. The version control metadata is distributed, so every clone is a complete history of the source code. Compare this with centralized systems like SVN or CVS where, if the central repository burns down, everything is lost!
# aptitude install git-svn
This is where we will initially copy the SVN repository.
$ mkdir beca_lims_portal_temp $ cd beca_lims_portal_temp
$ git svn init https://172.26.17.2/svn/beca_lims_portal/trunk/ --no-metadata
mnorling = Martin Norling <firstname.lastname@example.org> aorth = Alan Orth <email@example.com> root = Alan Orth <firstname.lastname@example.org> akihara = Absolomon Kihara <email@example.com>
$ git config svn.authorsfile ~/svnauthors
$ git svn fetch
When doing a normal git clone it will take everything we want from the temporary repository, while leaving behind all the SVN cruft that was there to support the git-svn stuff.
$ cd .. $ git clone beca_lims_portal_temp beca_lims_portal
You should see all your authors mapped from the SVN repository:
$ cd beca_lims_portal $ git log
Git uses two main types of tags: lightweight and annotated. A lightweight tag is very much like a branch that doesn’t change — it’s just a pointer to a specific commit. Annotated tags, however, are stored as full objects in the Git database. They’re checksummed; contain the tagger name, e-mail, and date; have a tagging message; and can be signed and verified with GNU Privacy Guard (GPG). It’s generally recommended that you create annotated tags so you can have all this information; but if you want a temporary tag or for some reason don’t want to keep the other information, lightweight tags are available too.
git tagcreates a "lightweight" tag that is basically a branch that never moves. Normally, you want to at least pass the
-aoption to create an unsigned tag.
git tag -a v0.2
Specify a certain commit by giving the commit's checksum (or the abbreviated checksum):
git tag -a v0.1 8e11e65
git push doesn't send tags to the remote origin; you have to tell it to do it manually.
$ git push origin v0.1
Push all tags which are not already on the remote origin:
$ git push origin --tags
If you want to revert a file in the current working revision to a past revision
$git checkout <commit_hash> filename
To edit a commit (like fixing a spelling or logic mistake):
git logand copy the first 5 or so characters from the ID of the commit you want to edit onto your clipboard.
pick d3adb33 Commit message, one line for each commit since the older one.
Sometimes you commit something without realizing you haven't properly configured your ~/.gitconfig. Simple amend the last commit:
$ git log -n1 commit 85f761ec52e4be90acd2dc7c9f5842e36ad7d783 Author: Alan Orth <firstname.lastname@example.org> Date: Sun Nov 21 05:07:48 2010 -0500 Initial Import of DSpace 1.6.2 $ git commit --amend --author 'Alan Orth <email@example.com>' ... vim/nano will pop up, save the commit $ git log -n1 commit 85f761ec52e4be90acd2dc7c9f5842e36ad7d783 Author: Alan Orth <firstname.lastname@example.org> Date: Sun Nov 21 05:07:48 2010 -0500 Initial Import of DSpace 1.6.2
Certain files, like database configuration files, need to be tracked but you don't want to push changes to the remote repo. This is different than using a
.gitignore file, as those files are not tracked in the repository! This allows you to have a generic database config in your repository without telling everyone your database password!
$ git update-index --assume-unchanged common/config
The opposite of the above:
$ git update-index --no-assume-unchanged common/config
The editor is used when you have to enter a commit message.
[core] editor = vim
[color] ui = auto [color "branch"] current = yellow reverse local = yellow remote = green [color "diff"] meta = yellow bold frag = magenta bold old = red bold new = green bold [color "status"] added = yellow changed = green untracked = cyan
git config -l