space, → | next slide |
← | previous slide |
d | debug mode |
## <ret> | go to slide # |
c | table of contents (vi) |
f | toggle footer |
r | reload slides |
z | toggle help (this) |
sudo apt-get install git-core
on Ubuntu/Debianhttp://kernel.org/pub/software/scm/git/git-1.7.3.5.tar.bz2
./etc/gitconfig
, ~/.gitconfig
,
.git/config
.$ git config --global user.name "Noufal Ibrahim"
$ git config --global user.email noufal@nibrahim.net.in
$ git init # Initialise a repository
Initialized empty Git repository in /tmp/foo/.git/
$ echo "This is a sample repository" > README
$ git status # Show status of files
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# README
nothing added to commit but untracked files present (use "git add" to track)
$ git add README
$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: README
#
$ git commit -m "Initial commit"
[master (root-commit) 199455a] Initial commit
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 README
$ git log # Full logs
commit 199455a2525a0a2fd712a7fe7e97c1e4efe87e18
Author: Noufal Ibrahim <noufal@nibrahim.net.in>
Date: Tue Jan 18 00:50:47 2011 +0530
Initial commit
$ git log --pretty=oneline # Formatting
199455a2525a0a2fd712a7fe7e97c1e4efe87e18 Initial commit
$ echo "\nOne more line\n">> README
$ git diff
diff --git a/README b/README
index 0ece930..c43f21d 100644
--- a/README
+++ b/README
@@ -1 +1,4 @@
This is a sample repository
+
+One more line
+
$ git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: README
#
no changes added to commit (use "git add" and/or "git commit -a")
$ git add README
$ git commit -m "Added one more line"
[master 0d47197] Added one more line
1 files changed, 3 insertions(+), 0 deletions(-)
git add
.git add -i
allows you to add pieces of changes.git diff
shows only unstaged diffs.git diff --cached
shows staged diffs..git
directory (or GIT_DIR
).Image from : http://www.slideshare.net/chacon/getting-git
git cat-file
..git/objects/
directory.objects/xx/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
git ls-tree
will give you details.Tree
(pointer to files)Parent
sAuthor
(Who made it + date)Committer
(Who put it into this DAG + date)Comment
describing changegit commit
(parent is HEAD, tree is index).references
git branch
command.git branch test
creates a branch called test
git checkout test
switches you to that branchHEAD
to refer to test
.docs
can be fast forwarded to master
.git branch --merged
shows all branches contained by the current
one.git branch --no-merged
shows all branches not contained by the
current one.reset
to before the merge to throw it away.git add
to mark it as done.git branch experimental 53222122668c23e704a6baf8059f871343c28d79
git rebase --continue
6
and 7
are dangling commits which have to be garbage collected.git rebase --interactive
is lots of fun.git rebase --abort
is to stop the rebase process.ver1.0
, ver2.0
etc.git tag
..git/refs/tags/
git tag
objects
which can be signed.git tag
with either -a
, -s
or -u
..git/refs/tags
will point to the tag object (not the commit).git stash
git stash list
shows list of all stashes.git apply
and pop using git pop
.remote
is a repository stored somewhere other than your local machine..git/refs/remote/<remotename>/
git remote
.git add remote upstream git@github.com:nibrahim/git-presentation.git
upstream
.git remote
(with -v
for locations).git remote rm
git update
fetches latest information from the remotegit branch --track local_name remote_name/remote_branch_name
local_name
will follow remote_branch_name
on remote_name
.fetch
ed herepush
ed there.git fetch <remote>
pulls in commits from <remote>
.git merge
.git pull
= git fetch
+ git merge
.git pull <remote> <ref>
<remote>/<ref>
into current branch here.git push <remote>
sends local commits to <remote>
.git push <remote> <ref>
<remote>/<ref>
.<ref>
is srcref:destref
.git push <remote> :<branch>
will delete <branch>
from the remote (empty src).--tag
.test
is actually refs/heads/test
.v1.0
is actually refs/tags/v1.0
.origin/master
is actually refs/remotes/origin/master
.treeish
is a way of referring to a commit.53222122668c23e704a6baf8059f871343c28d79
53222
)master@{yesterday}
means where the master
was yesterday.git log "master@{6 months ago}"
master@{5}
points to the Nth previous value of master
.git log
and then git log "master@{5}"
.foo^2
2nd parent of merge commit foo
.foo~2
gives us the 2nd grandparent of a foo
.foo~2
is the same as foo^^
(first parent of first parent of foo).git log "master~60^2^"
(on notes repository)^{tree}
to a commit fetches the tree associated with that commit.git cat-file -p "master^{tree}"
:path/to/file
to the end of a ref returns the SHA of the blob for that file.git cat-file -p "master^{tree}:.gitignore"
.gitignore
as on master
.ref1...ref2
gives you commits between these two refs.git log test...master
bad
, a good
and a test