Git常用命令筆記

來源:互聯網
上載者:User

Git常用命令筆記 git 在提交之前撤銷add操作 問題: 在使用git時,在未添加.ignore檔案前使用 git add . 將所有檔案添加到庫中,不小心將一些不需要加入版本庫的檔案加到了版本庫中。由於此時還沒有提交所以不存在HEAD版本,不能使用 git reset HEAD命令。 解決: 使用 git rm -r --cached . ps:注意最後是有點的。 ---------------------------------------改寫最後一次提交--------------------------------------- git commit -m'改寫最後一次提交' git add forgotten_file //補上忘記提交的檔案 git commit --amend ----------------------------------------remote-------------------------------------------- git remote add [shortname] [url] //添加遠程倉庫 git remote -v //列出遠程倉庫 git remote show [remote-name] //列出遠程倉庫詳細資料 git remote rename old-name new-name //遠程倉庫重新命名 git remote rm [remote-name] //刪除遠程倉庫 ----------------------------------------fetch----------------------------------------------- git fetch [remote-name] //將遠端的資料拉到本地倉庫,並不自動合并到當前分支,仍需手工合并。 ---------------------------------------tag------------------------------------------------------- git tag v1 //建立標籤 git tag -a v1 -m '建立標籤' git show v1 //查看標籤版本資訊 ----------------------------------linux 下自動補全功能------------------------------------ 在git源碼中 contrib/completion 目錄中的 git -completion.bash 複製到自己的使用者目錄中。並把下面內容添加到你的 .bashrc檔案中 source ~/.git-completion.bash ---------------------------------設定Git命令別名--------------------------------------------- git config --global alias.co checkout //設定checkout 命令別名 git config --global alias.br branch //設定branch 命令別名 git config --global alias.ci commit //設定commit 命令別名 git config --global alias.st status //設定status 命令別名 git config --global alias.last 'log -1 HEAD' //查看最後一次提交資訊 git config --global alias.visual "!gitk" //啟動gitk。運行外部命令,只需在命令前加上 ! 。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.