git常用命令

來源:互聯網
上載者:User

標籤:UNC   clone   rem   lang   重設   git clone   它的   remote   tor   

# 下載一個項目和它的整個代碼曆史$ git clone [url]

# 添加指定檔案到暫存區$ git add [file1] [file2] ...

# 添加目前的目錄的所有檔案到暫存區$ git add .

# 提交暫存區到倉庫區$ git commit -m [message]
# 提交暫存區的指定檔案到倉庫區$ git commit [file1] [file2] ... -m [message]


# 列出所有本地分支$ git branch

 

# 列出所有本地分支和遠程分支$ git branch -a


# 建立一個分支,但依然停留在當前分支$ git branch [branch-name]


# 建立一個分支,並切換到該分支$ git checkout -b [branch]

# 切換到指定分支,並更新工作區$ git checkout [branch-name]


# 切換到上一個分支$ git checkout -


# 刪除分支$ git branch -d [branch-name]


# 顯示有變更的檔案$ git status

# 顯示當前分支的版本曆史$ git log


# 顯示暫存區和工作區的代碼差異$ git diff


# 顯示某次提交的中繼資料和內容變化$ git show [commit]


# 從本地master拉取代碼更新當前分支:branch 一般為master
$ git rebase [branch]



#更新遠程倉儲
$ git remote update

# 取回遠程倉庫的變化,並與本地分支合并$ git pull [remote] [branch]


# 上傳本地指定分支到遠程倉庫$ git push [remote] [branch]

# 重設暫存區與工作區,與上一次commit保持一致$ git reset --hard
 
 

git常用命令

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.