SITCON 2013, 2014 總召
git
確認sudo apt-get install git
sudo yum install git
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git config --global color.ui true
git config --global core.editor vim
git config --global alias.co commit
git config --global alias.lg "log --color --graph --all --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --"
--global
?git help <command>
git init
touch README.md
git status
git add README.md
git add .
git reset <file>
git status
git diff
git diff --cached
git commit
git commit -m "first commit"
git commit -a
git log
git show <revisions>
git rm <file>
git rm --cached <file>
git mv <file>
git checkout <revision>
git checkout <revision> <file>
git stash
git stash save "message"
git stash list
git stash pop
git stash show -p <revision>
git reset <revision>
git reset --hard <revision>
git revert <revision>
git remote add origin https://github.com/denny0223/workshop.git
git remote
git remote -v
git remote show origin
git push -u origin master
git push origin master
git push
git branch
git branch -a
git branch -v
git branch -vv
git config --global credential.helper cache
git config --global credential.helper "cache --timeout=3600"
git clone
git pull
git fetch
+ git merge
git mergetool
git pull --rebase
git branch <branch name>
git checkout -b <branch name>
git push <remote> <local_branch_name>:<remote_branch_name>
git merge
git merge --no-ff
git cherry-pick <revision>
inotifywait -rm --format '%w%f %e' -e create -e close_write .
git init
echo test > file
git add file
SHA1 of "blob 5␀test␊"
printf "blob 5\000test\n" | xxd
printf "blob 5\000test\n" | shasum
echo test | git hash-object --stdin
git cat-file -p 9daeafb9864cf43055ae93beb0afd6c7d144bfa4
cd .git/objects/9d/
[denny@X230 9d]$ python
Python 2.7.5 (default, Nov 3 2014, 14:26:24)
[GCC 4.8.3 20140911 (Red Hat 4.8.3-7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> fd = open("aeafb9864cf43055ae93beb0afd6c7d144bfa4", "rb")
>>> line = fd.read()
>>> import zlib
>>> zlib.decompress(line)
'blob 5\x00test\n'
git cat-file -p 8b9af3b
tree 993624220e92bb14b1703b6005dccfda913e95bc
parent a5d55500219b63ac21bb3977ae1a69bf5f1f793f
author Denny Huang <[email protected]> 1407702807 +0800
committer Denny Huang <[email protected]> 1407702807 +0800
update
git add --patch
git commit --patch
git commit --amend
git commit --amend --date="Mar 15 00:00 2014"
git rebase -i <revision>
git reflog
git diff <revision>
git diff master@{2014-07-01}
git diff master@{"1 month ago"}
git log -p --stat
git log --oneline
git log --graph
git log --abbrev-commit
git log --pretty=%an
git whatchanged
git log --author="Denny Huang"
git log --since={2014-07-01} --until="1 week ago"
git log -p -i -G 'regex'
git blame <filepath>
git init --bare
git clone ///path/to/repo
git clone ssh://[username]@[host]:[port]/path/to/repo
.git/hooks/
git help githooks
Halloween Bash Profile Generator
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/ (.)/(\1)/'
}
export PS1="\h:\W \u\$(parse_git_branch)$ "