工做中使用總結,很早以前在CSDN博客上寫過一篇,加上新的,從新再掘金上再寫一篇吧,爲所謂重複造輪子,只是爲了讓本身再熟悉下,總結下。
git
ssh-keygen -t rsa -C "your_email@youremail.com"
vim ~/.ssh/id_rsa.pub // key的保存地址
複製代碼
git config --global user.name "your name"
git config --global user.email "your_email@youremail.com"
git config -l // 查看全部git配置
vim .git/config // 查看git的配置文件
git config http.postBuffer 10240000 // 設置緩存大小
複製代碼
git remote add upstream git@github.com:yourName/yourRepo.git
git remote
git fetch remoteName
git fetch -p(刪除相應分支) upstream(remote name) // 這將更新名稱爲upstream 的遠程repo上的全部branch的最新commit-id,將其記錄,可是不會pull下來
or
git fetch upstream branchName // 某個分支
複製代碼
git branch --set-upstream-to=<upstreamName>/<branch> <CurrentBranch>
// 而後就是拉取了
git pull upstream branchName
git pull // 設置了本地分支對應的遠程分支後,git pull後的遠程分支能夠省略
複製代碼
git branch // 顯示本地全部分支
git branch -a/--all // 顯示全部remotes下的全部分支
git checkout branchName // 切換到branchName分支
git checkout -b branchName // 在當前分支的基礎上新建branchName分支
git checkout -D branchName // 刪除branchName分支
// 刪除遠程分支
git branch -r -d origin/branchName
git push origin:branchName
複製代碼
git commit -m "Detail"
or
git commit
:w
:qa! / :wq
複製代碼
git push origin master == git push origin HEAD:master
git push -f origin master // -f 強制推送,慎用
複製代碼
git status 目錄路徑(./) // 顯示該目錄下全部有改變的文件
git diff 目錄路徑或者具體的文件路徑 // 顯示目錄路徑下全部文件或者具體文件的改動
git checkout 目錄路徑/具體文件路徑 // 丟棄改動
複製代碼
1). 進入非空目錄,假設是 /workdir/project
2). git clone --no-checkout git@github.com:tuchuantao/Todo.git temp
3). mv temp/.git . #將 temp 目錄下的 .git 目錄移到當前目錄
4). rmdir temp
5). git reset --hard HEAD
複製代碼
1). git fetch upstream branchName // 先fetch相應的分支
2). git rebase // 假如此時有衝突,會顯示,解決衝突後 git rebase --continue,沒有固然更好
複製代碼
©愛穿襯衫的程序員程序員