廖雪峯的《Git教程》git
git version which git
git config --global user.name "MiracleWong" git config --global user.email "youremail@example.com" git config --global color.ui auto
git config --global user.name git config --global user.email git config --global color.ui
cd project git init git init project
git status
git add
命令實際上就是把要提交的全部修改放到暫存區(Stage)github
git add readme.txt
git commit
就能夠一次性把暫存區的全部修改提交到分支app
git commit -m "add readme.txt"
git log git log --pretty=oneline git log --pretty=oneline --abbrev-commit 顯示前6位commit-id
HEAD 表示當前版本,上個版本HEAD^,上上個版本HEAD^。ssh
git reflog
git reset --hard HEAD^
git diff HEAD -- readme.txt
git reset HEAD readme.txt
git checkout -- readme.txt
git rm file git commit -m "dekete file"
git checkout
實際上是用版本庫裏的版本替換爲工做區的版本fetch
git checkout -- test.txt
ssh-keygen -t rsa -C "youremail@example.com"
git remote add origin git@github.com:michaelliao/learngit.git
git push -u origin master 第一次推送master分支的全部內容 git push git push origin master
git clone git@github.com:michaelliao/gitskills.git
git branch <name>
git checkou -b dev
git branch
git checkout master
git merge dev git merge <name>
git branch -d <name>
--bo-ff
強制禁用Fast-Forward模式,生成一個新的commit信息,從分支歷史上能夠看出分支信息ui
git merge --no-ff -m "merge with no-ff" dev
master 分支應該是很是穩定的,僅用來發布新版本,平時不在上面幹活。
幹活在dev分支上url
git stash
git stash apply stash@{0} git stash drop (刪除儲存的現場)
git stash pop
git stash list
git branch -D <name>
git remote -v
git push origin master git push origin dev
git checkout -b dev origin/dev
git branch --set-upstream dev origin/dev
git tag v1.0
git tag
git tag v0.9 commit-id
git show <tagname>
用-a指定標籤名,-m指定說明文字:操作系統
git tag -a v0.1 -m "version 0.1 released" commit-id
git tag -s v0.2 -m "signed version 0.2 released" commit-id
git tag -d v0.1
git push origin v1.0
git push origin --tags
git push origin :refs/tags/v1.0
The world’s leading software development platform · GitHub
碼雲 Gitee — 開源中國基於 Git 和 SVN 的代碼託管和協做開發平臺
Coding - 代碼託管 項目管理 WebIDE 企業服務.net
git config --global color.ui true git config --global color.ui auto
git add -f App.class
git check-ignore -v App.class
git config --global alias.st status git config --global alias.co checkout git config --global alias.ci commit git config --global alias.br branch git config --global alias.unstage 'reset HEAD' git config --global alias.last 'log -1' 顯示最後一次提交的信息 git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true ignorecase = true precomposeunicode = true [remote "origin"] url = git@github.com:michaelliao/learngit.git fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] remote = origin merge = refs/heads/master