25個每個人都應(yīng)該知道的Git命令

1、初始化本地Git存儲庫
git init2、創(chuàng)建遠(yuǎn)程存儲庫的本地副本
git clone ssh://git@github.com/[username]/[repository-name].git3、檢查狀態(tài)
git status4、將文件添加到暫存區(qū)
git add5、將所有新文件和更改過的文件添加到登臺區(qū)域
git add -A6、提交更改
git commit -m "[commit message]"7、刪除文件(或文件夾)
git rm -r8、列出分支(星號表示當(dāng)前分支)
git branch9、創(chuàng)建一個新分支
git branch10、刪除分支
git branch -d11、創(chuàng)建一個新分支并切換到該分支
git checkout -b12、克隆一個遠(yuǎn)程分支并切換到該分支
git checkout -b13、重命名本地分支
git branch -m [old branch name] [new branch name]14、切換到分支
git checkout [branch name]15、將一個分支合并到活動分支中
git merge [branch name]16、將一個分支合并到一個目標(biāo)分支
git merge [source branch] [target branch]17、將更改存儲在不合適的工作目錄中
git stash18、刪除所有隱藏的條目
git stash clear19、將分支推送到你的遠(yuǎn)程存儲庫
git push origin20、將更改推送到遠(yuǎn)程存儲庫
git push21、將本地存儲庫更新為最新的提交
git pull22、從遠(yuǎn)程存儲庫中提取更改
git pull origin23、添加一個遠(yuǎn)程存儲庫
git remote add origin ssh://[email protected]/[username]/[repository-name].git24、查看更改
git log25、合并前預(yù)覽更改
git diff [source branch] [target branch]結(jié)論
希望本指南內(nèi)容對你有所幫助。還有其他我們錯過的命令嗎?如果是這樣,請?jiān)谠u論中讓我知道!
感謝你的閱讀。
學(xué)習(xí)更多技能
請點(diǎn)擊下方公眾號
![]()
評論
圖片
表情
