-
Notifications
You must be signed in to change notification settings - Fork 1
Advanced topics
For the curious, and maybe for later workshops and tutorials here are a few pointers to some advanced git tools or commands. Some of them prove very useful in large projects, some allow you to recover from disasters, etc...
###Git Tags Tags are named pointers to a commit. Contrary to a branch, you cannot commit on top of them. Checking out one of them puts you in a detached HEAD. They are used mainly as bookmarks in the development process.
There are two kinds of hooks:
- client side
- server side
client side hooks are script run on your client before you try to commit some change and for instance check whether your user has a name and email address, or if the code sticks to the coding guidelines, and in general if your commit verifies any condition that you may be able to script.
On the server side, you may want to update some website that handles your merge requests, or send a few e-mails when a specific branch is updated, or even run continuous integration tests after any new commit that you receive, the possibilities are numerous.
Git stores the history and file data in objects, identified by their SHA1 hash. They are 3 types trees, commits and files. Manipulating them by hand is possible and educational...
Philosophical discussion, heated debate among development teams. Rebasing was not even mentioned in the tutorial since it rewrites history, and this is dangerous for inexperienced committers. Rebased code history do look much simpler though. The thought process that lead to a bug fix should be kept intact, say some developers and rebasing squashes them. And the debate goes on...
Handling subprojects, aggregating projects in a meta project, all that is possible in Git, but is most often frowned upon by many even experienced git users. What are the limits of each method, should you even use them at all? (see http://git-scm.com/book/en/Git-Tools-Submodules and http://git-scm.com/book/en/Git-Tools-Subtree-Merging)
svn-git allows you to use local git goodness on a remote svn server. To put it differently, when you don't have your say on the scm, stop whining and use your favourite SCM without forcing others.
The objects stored in your git repo may accumulate over time. Learn to use git repack, prune, and so on..
Also, the SHA1 has for each file garranties you that if an object is corrupted on the disk, you will be notified. It's an invaluable built-in security that is the start of fantastic adventures: How to recover from file corruptions? Discover git-fsck
https://github.com/rwos/gti . Have fun.
To show in your prompt the current branch, and the status of the branch (clean, things to commit, etc...), you may add $(__git_ps1)) to your PS1 shell variable.
source /etc/bash_completion.d/git
export GIT_PS1_SHOWDIRTYSTATE=true
#$(__git_ps1) is the interesting bit here
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(__git_ps1)$ '