Git In The Land of Version Control Systems A tutorial on getting git
Version Control Systems Some History
In the beginning RCS
Then... CVS & SVN
When Linus could scale no more Bitkeeper
Which lead to... Git, arch, Bazaar and Mercurial
Getting Started ● You need one tool and that's git. – On debian its a package called git-core – You can get the source from ● But there are others: – Meld – diff viewer – Egg – emacs mode for git – Gitg /gitk – view your emacs tree
Configuring git ● There's a file called.gitconfig in your home directory. ● It's an INI-style file which you could edit by hand. But you can always use the git config command instead. ● Things you should set: – Your and name – Aliases, handy
Getting Started On Your Project ● Open a new directory git init ● You should now see a.git directory ● You are on your way :)
Getting Started On Your Project ● The.gitignore file is in the root of your git repository. It holds patterns of files you want to ignore like: – # is a comment (e.g. # Rob's gitignore) – ! is a negation (e.g. !a.c everything but a.c) – * is anything (e.g. *.log) – [] denote options (e.g. i.[oa] – ignores i.a and i.o).
Git core concepts #1 & 2 #1 Your entire git repository is on your machine. That means everything is local So all operations cost a lot less #2 There is an area before you commit called the stage The stage is how you manage the files pre- commit
Getting Working With git git status, git diff, git commit, git branch – do exactly what you they do in svn git add – adds files or parts of files to a commit git checkout – switches from branch to branch git commit – commits your changes to your git repo.
Practical: Set up a git repository
Sharing the love When you have a git repo you can share it: ● Via SSH ● Via git daemon – not recommended ● Via Apache ● Via github git push sends your changes to a remote repository. git pull gets the changes from another repository git remote manages your list of remote repositories
Git core concepts #3 & #4 #3 The.git directory is all you need to share you entire history. 4# Each change is a patchset. They form a directed acyclic graph (as in a set of connected nodes similar to a tree). So given your graph of patchesets I should be able to reconstruct your repository at any point in time.
Practical: Share my git repo
Git core concepts #5 & #6 #5 Branching is a low cost operation. Merging mostly just works. Branch and merge regularly. #6 When you want to refer to a git commit, use its SHA.
Git power Once you get branches some commands start to make sense: ● git stash – need to flip branches before a commit? ● git bisect – work out which patchset killed your build ● git rebase – apply a patch set to a different part of the DAG and change history **CAREFULL!**
Git power extras ● Hook scripts, found under.git ● gitk – visual help with your git ● Git Bash completion – handy :) ● git cherry-pick – apply a single patch to your tree
Learning more ● Gitcasts - ● Git ready blog - ready ● Pragmatic Version Control Using Git – book from the PragProg stable ● Github guides -