Git 命令使用筆記

小白篇: Git新手上路,讓你快速掌握Git的基本使用

#添加電腦ssh密鑰到git:
C:\Users\evan\.ssh\id_rsa.pub  -- 複製 --->> git 個人資料設置--SSH密鑰--公鑰  輸入複製內容 

#拉取遠程倉庫項目
git clone [email protected]:molashaonian/git_command.git

#初始化當前目錄git
git init

#查看狀態
git status

#添加所有
git add .

#提交當前分支到本地倉庫
git commit -m "message"

#查看所有分支信息
git branch -a

#本地建立並且選擇dev分支
git checkout -b dev

#本地選擇test分支
git checkout test

#建立本地分支與遠程倉庫的關係
git remote add origin http://10.0.98.7:8080/blue-whale/answer-api.git

#首次推到遠程倉庫
git push -u origin master

#推送更新到關聯的遠程倉庫
git push origin master

#查看遠程倉庫信息
git remote -v

#更新從關聯的遠程倉庫
git pull

#關聯遠程倉庫
git branch --set-upstream-to=origin/test test

#查看本地倉庫與遠程倉庫關聯信息
git branch -vv

#test分支合併到當前分支
git merge test

#刪除test分支
git branch -d test

#合併本地分支並提交
git checkout -b duyuan origin/duyuan

git checkout -b preProduct origin/preProduct

git merge duyuan

git push
 
#合併遠程分支
git merge origin/duyuan

#查看日誌
git log --graph --pretty=oneline --abbrev-commit

#提交記錄合併爲一條(變基)
git rebase -i  [startpoint]  [endpoint]
git rebase -i HEAD~~
git rebase -i HEAD~3

pick --修改爲--> s
保存退出:wq

填寫git push message
This is the 1st commit message 

填寫rebase message
This is the commit message #2 

Esc 保存退出:wq

後續更新。。。。。。

關注公衆號,分享乾貨,討論技術

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章