當用戶忘記在命令git commit
後忘記發出git push
命令時,會出現此問題。使用git時,請務必確保基本步驟。
In an ideal cycle while working with git, always check the following git commands were used sequentially in the following order:
git pull
git add
git commit
git push
我個人避免廣大發布有關堆棧git的問題,因爲我總是吻合我的git命令的活動還與上面的序列。
我創建的首字母縮寫,以確保我不會忘記,我hopoing同樣可以是這是很有用:
pacp (read it as: pack push where (p=git push, a=git add, ck=git commit, push=git push).
我的方式來記住混帳推,添加,提交,拉是:
get pack push (meaning: git the pack and then push).
總之記住要「包」,然後「推」。
解決的問題: 我想補充一點,是我最常用的恢復Git命令:
git checkout -- path/to/file/fileName.something #undo changes in file
The above undoes the changes in a file...similar can be applied for multiple files using * for file name, similarly can be applied to multiple directories separated by space.
git reset filename.txt
The above removes the file from stage...after this command we can safely do git commit and git will only commit those files we are in stage which means the file "filname.txt" won't get committed)
git pull origin your_intended_branch
變化與從your_intended_branch最新合併這基本上合併了你承諾但沒有推動的變化。一旦一切順利,只需按下:
git push
或者OP可能已經重新啓動了它們的分支。 – knittl
我聽說拉不好,因爲它會以你通常不想要的方式合併。 Peronally,我喜歡保持我的歷史線性。當我遇到與提問者相同的錯誤時,我該如何實現? –
我試過#git pull origin devops_branch_22112016出現錯誤:對以下文件的本地更改將被合併覆蓋: www/index.html 請在提交更改或隱藏它們後再進行合併。 正在中止 –