標籤:
1.設定英文版的git
echo "alias git=‘LANG=en_GB git‘" >> ~/.bashrc
重啟
設定中文版
加個# echo "#alias git=‘LANG=en_GB git‘" >> ~/.bashrc
2.git init
初始化git
3.git config
配置git,使用者名稱,郵箱等等
4.git add "file"
添加檔案
5.git commit -m "commit"
添加註釋
6.git status
查看目前狀態
7.git log
查看日誌
8.git reset --hard commit_id
回到某一個特定的版本,commit_id版本號碼,HEAD目前的版本
HEAD^前一個版本
9.git reflog
查看設定日誌
10.git diff
查看尚未提交的變化
11.git remote add origin http://....../....git
與遠端伺服器相關聯
12.git push -u origin master
推送到遠端伺服器
13.git clone http://...... .git
從遠端伺服器複製一個git項目。
14.ssh-keygen -t rsa -C "[email protected]"
產生兩個檔案id_rsa 和 id_rsa.pub,其中id_rsa為私密金鑰,
id_rsa.pub為公開金鑰。
15.git branch branch_name
建立分支
git branch [-a -r -v]
查看分支
git branch -d branch_name
刪除分支
git branch -D branch_name
強制移除分支
16.git checkout branch_name
切換分支
git checkout -b branch_name
建立分支並切換分支
17.git merge branch_name
將分支合并到當前分支
git merge --no-ff -m "merge" branch_name
將分支合并,禁用Fast forward模式
18.git stash
隱藏當前的現場
git stash list
查看隱藏的現場
git stash apply
恢複現場(但不刪除stash內容)
git stash drop
刪除
git stash pop
恢複並刪除stash
19.git log --graph [--pertty=oneline --abbrev-commit]
查看分支的合并情況
20.git remote [-v]
查看遠程庫
21.git push origin branch_name
推送branch_name到遠程倉庫
22.git checkout -b branch_name origin/branch_name
建立遠程分支
23.git branch --set-upstream branch_name origin/branch_name
本地branch_name與遠端branch_name串連
24.git pull
抓取遠程分支的最新的提交
25.git tag tag_name
打標籤
git tag
查看標籤
git tag -a tag_name -m "tag_info"
指定標籤資訊
git tag -s tag_name -m "tag_sig"
使用PGP簽名標籤
26.git show tag_name
查看標籤資訊
27.git push origin tag_name
推送一個本地標籤
git push origin --tags
推送全部未推送的本地標籤
28.git tag -d tag_name
刪除一個本地標籤
git push origin :refs/tags/tag_name
刪除一個遠端標籤
git常用命令