Git常用命令

2021-07-25 02:30:46 字數 1288 閱讀 5910

git(版本控制系統):據說又是gobal information tracker

以下是git命令整理:

1、git init 所在目錄初始化為git倉庫

2、git add filename 新增修改到暫存區

3、git commit -m "describtion" 提交修改到當前分支

4、git status 檢視是否有沒被提交的修改

5、git diff filename 檢視檔案修改處

6、git log --pretty=oneline 檢視提交日誌

7、git reset --hard head^ 返回上乙個版本(head表示當前版本)

8、git reset --hard id 返回某一版本

9、git reflog 檢視命令歷史

10、git checkout -- filename 撤銷工作區的修改(版本庫里的版本替換工作區的版本)

11、git reset head filename 撤銷暫存區的修改

12、git rm filename 刪除檔案

13、git remote add repo-name addr 新增遠端倉庫

14、git push (-u) repo-name master 將本地master分支推送到遠端庫(第一次加「-u」)

15、git checkout (-b) branch-name 切換到分支(建立並切換加"-b")

16、git branch 檢視所有分支

17、git merge branch-name 合併指定分支到目前分支(發生衝突時,直接修改提交就能解決衝突)

18、git branch -d branch-name 刪除分支

19、git merge --no-ff -m "describtion" branch-name 以no fast forward方式合併,能夠看到歷史分支

20、git stash 儲存工作現場

21、git stash list 檢視stash歷史

23、git stash pop 恢復並刪除stash

24、git remote -v 顯示遠端庫資訊

25、git checkout -b branch-name origin/branch-name 建立和遠端分支對應的分支

26、git push repo-name branch-name 將分支推送到遠端庫

27、git branch --set-upstream branch-name origin/branch-name 關聯本地和遠端分支

28、git pull 抓取遠端新提交

常用命令 Git 常用命令大全

安裝教程可參照 廖雪峰老師的安裝教程。git config 在git中,使用git config 命令來配置 git 的配置檔案,git配置級別主要有3類 1 倉庫級別 local 本地 git 倉庫級別配置檔案,作用於當前倉庫。優先順序最高 2 使用者級別 global,全域性配置檔案,作用於所有...

git 常用命令

檢視是否存在檔案需要上傳 git status git add git commit m 建立遠端倉庫 git remote add origin 116.255.146.153 ruby cd work daily project.git 更新git fetch 116.255.146.153 r...

git常用命令

詳細 1,git log p 命令來顯示每一次提交與其父節點提交內容之間快照的差異。2,為了檢視載入 staged 而並未提交 not committed 的內容差異,可以使用 git diff stage 命令 在git 1.6之前的版本中,使用 cached 適應情形 在執行git commit...