前言
記錄idea使用git更新並提交代碼遇到的一點疑惑。
一、更新
因為不太了解using stash與using shelve的區別,所以百度了一下。我自己一直用的using stash。
有兩種方式,如下:
1.1 直接pull
這就是 git pull。相當於git fetch+git merge
1.2 通過update project 按鈕
就是這種方式有點疑惑。
標號1容易理解,直接選擇從默認分支更新即可。
標號2的含義查了下,如下:
兩個命令都是把代碼擱置,只是stash是git原生的。shelve是idea獨有的。
- shelve存在當前項目下.idea/shelve里
- 查看shelve,打開version control面板,點開shelf
- unshelve,在面板里選擇你需要unshelve的條目即可
git shelve doesn't exist in Git. Only git stash: when you want to record the current state of the working directory and the index, but want to go back to a clean working directory. which saves your local modifications away and reverts the working directory to match the HEAD commit. You had a 2008 old project git shelve to isolate modifications in a branch, but that wouldn't be very useful nowadays. As documented in Intellij IDEA shelve dialog, the feature "shelving and unshelving" is not linked to a VCS (Version Control System tool) but to the IDE itself, to temporarily storing pending changes you have not committed yet in changelist. Note that since Git 2.13 (Q2 2017), you now can stash individual files too.
git中不存在git shelve。
只有git儲備:
當您希望記錄工作目錄和索引的當前狀態,但又希望返回到一個干凈的工作目錄時。
它保存您的本地修改並恢復工作目錄以匹配HEAD提交。
您有一個2008年的老項目git shelve來隔離分支中的修改,但這在現在不是很有用。
正如Intellij IDEA擱置對話框中所記載的那樣,特性“擱置和解除擱置”並沒有鏈接到VCS(版本控制系統工具),而是鏈接到IDE本身,用來臨時存儲尚未提交的掛起的更改。
注意,自從Git 2.13(2017年第二季度)以來,你現在也可以隱藏單獨的文件了。
嫌不夠詳細,可以去官網地址再查看!
其實直接用using stash就行了。
我平常就是直接用這個,要是報錯了,就自己手動的執行1,然后再git pull,再執行2,手動合並沖突。就是相當於先git stash,將本地變更存儲起來,然后再從遠程倉庫更新代碼git pull到本地倉庫及編碼區,再執行2,手動merge下沖突。
別出現下面這位老哥的錯誤就行了:
二、提交
idea添加push按鈕到工具欄:
