master = branch master
HEAD = alias/pointer to latest commit
HEAD^ or HEAD~1 = alias/pointer to second latest commit
origin = remote path
Create remote repo
# ssh git@example.com
# mkdir my_project.git
# cd my_project.git
# git init --bare --shared=group # Directory hooks/, info/, objects/, refs/, HEAD, description, config will be created
# git repo-config core.sharedRepository "group"
# chgrp -R gitgrp .
# chmod -R g+ws .
# git-update-server-info # If plan to serve via HTTP
# exit
$ cd my_project
$ git init
$ git add *
$ git commit -m "Initial import"
$ git remote add origin git@example.com:my_project.git
$ git remote add origin file:///home/repo/git/my_project.git
$ git remote add origin ssh://user@xx.xx.xx.xx/home/repo/git/my_project.git
$ git push origin master
$ mkdir ~/git_sandbox
$ cd ~/git_sandbox
$ git clone file:///home/repo/git/my_project.git
$ git config branch.master.remote origin
$ git config branch.master.merge refs/heads/master
# mkdir my_project
# cd my_project
# git init # Directory .git will be created
# git config receive.denyCurrentBranch "ignore" # in order to let others do git push
# git repo-config core.sharedRepository "group"
# chgrp -R gitgrp .
# chmod -R g+ws .
cd <repo.git>/ # Enter inside the git repo
git config core.sharedRepository group # Update the git's config
chgrp -R <group-name> . # Change files and directories' group
chmod -R g+w . # Change permissions
chmod g-w objects/pack/* # Git pack files should be immutable
chmod g+s `find . -type d` # New files get group id of directory
where:
<repo.git> is the bare repository directory, typically on the server (e.g. my_project.git/).
<group-name> is the group name for git users (e.g. users).
cd <project_dir>/ # Enter inside the project directory
git config core.sharedRepository group # Update the git's config
chgrp -R <group-name> . # Change files and directories' group
chmod -R g+w . # Change permissions
chmod g-w .git/objects/pack/* # Git pack files should be immutable
chmod g+s `find . -type d` # New files get group id of directory
where:
<project_dir> is the project directory containing the .git folder.
<group-name> is the group name for git users (e.g. users).
$ git config --global diff.tool vimdiff
$ git config --global merge.tool vimdiff
$ git config --global --add difftool.prompt false
$ git status
$ git status -s | cut -c4-
$ git status --porcelain | sed s/^...//
$ git diff --name-only
$ git remote -v
$ git remote show origin
$ git diff
$ git diff HEAD
$ git diff --cached
$ git show HEAD
$ git log
$ git log --name-status
$ git log --author=Linus --graph --oneline -5
$ git add <filename>
$ git add -i # add interactively
$ git add . # add to index only files created/modified and not those deleted
$ git add -u # add to index only files deleted/modified and not those created (Files that already under git control)
$ git add -A # do both operation at once, add to index all files
$ git add --all # do both operation at once, add to index all files
$ git ls-files --modified | xargs git add
$ git ls-files -m | xargs git add
$ git reset <filename>
$ git reset HEAD <filename>
$ git rm <filename>
$ git commit -a -m "added key scanning"
$ git push origin master
$ git fetch
$ git pull (actually it do git fetch, follow by git merge)
$ git checkout <filename>
$ git checkout HEAD <filename>
$ git reset --hard
$ git reset --hard HEAD^
$ git reset --hard HEAD~1
$ git revert hash
$ git blame ui_key.c
$ git tag <RELEASE_V05>
$ git tag -l
$ git checkout <tagname>
$ git branch <new-br-name>
$ git checkout <br-name>
$ git checkout -b <new-br-name> <base>
(actually it do git checkout <base>, follow by git branch <new-br-name>, follow by git checkout <new-br-name>)
$ git branch -d <br-name>
$ git merge <br-name>
$ git stash
$ git stash list
$ git show a5915b6
$ git difftool HEAD^ HEAD
$ git diff stash@{0}
$ git diff stash@\{0\} (Need a escape seq "\" in tcsh)
$ git stash pop (stash@{0} will be remove)
$ git stash apply stash@{0} (stash@{0} will be remain)
$ git stash drop stash@{0}
[etienne@ubuntu /home/repo/git]$ sudo git cvsimport -d $CVSROOT -C proj.git -r cvs -k cvsprojrepo
[etienne@ubuntu ~/git]$ git clone file:///home/repo/git/proj.git/