![](/img/trans.png)
[英]How can I see what changes have been made in a git repository without pulling it into my working tree
[英]How do I merge changes without pulling from a GIT repository?
感謝您的光臨。 毫無疑問,我可能在問題中使用了錯誤的術語,所以讓我解釋一下這個問題:
push
之前沒有pull
。 所以,那是我的問題。 我使用此SO帖子將代碼實例reset
為我所做的最后一次成功提交(上面的步驟3),並且效果很好。 因此,現在我可以構建了,所有工作都恢復了原樣。
雖然我的本地代碼的副本,現在看起來又大,我不能push
它GIT沒有首先做一個pull
的什么已經是在回購協議。 不幸的是,當我進行pull
時,我的所有工作都被覆蓋,並且沒有給我合並的機會。
有什么建議嗎?
如果已經發生了強制推送,並且您覺得包裝箱上的存儲庫狀態就是您希望存儲庫所在的狀態,則只需再次執行git push -f
。
為什么不將本地更改分支到單獨的分支。 將倉庫拉到您的主分支。 本地合並。 然后推回倉庫?
是的,您可以在不拉動的情況下在本地合並更改,然后在修復混亂后將其推回到遠程存儲庫。
我相信您在遠程倉庫中的圖表是:
C1 - C2
而您的本地git是:
C1 - C1'
因為您的C1'不是基於C2的任何內容,所以您無法提交(除非您強行執行)
您可以通過首先git fetch將您的本地git圖形更新為以下內容來解決此問題:
C1 - C1' (local/master)
\- C2 (origin/master)
然后您可以合並
git merge origin/master
您可能會遇到沖突。 修復所有問題后,您將得到如下圖:
之后
C1 - C1' ---------- C3 (local/master)
\- C2 (origin/master) -/
然后,您應該可以在沒有--force的情況下進行推送
從git help push
:
For a failed update, more details are given:
rejected
Git did not try to send the ref at all, typically because it is not a fast-forward and you did not force the update.
remote rejected
The remote end refused the update. Usually caused by a hook on the remote side, or ...
git pull
命令是git fetch && git merge
的快捷方式(如果使用--rebase
選項, --rebase
git rebase
)。 因此,您可以先獲取,然后手動合並遠程更改。 git status
告訴您是否在上游,並且分支是否可以輕松更新:
Your branch is behind 'origin/master' by 4 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
Git提示非常方便,可以快速知道是否存在要檢索和合並的遠程更改。 在git fetch
之后看到提示中的“ u-4
”,以及git log ..@{u}
報告的四個傳入提交的列表:
(master $ u= origin/master)]$ git fetch
(master $ u-4 origin/master)]$ git log ..@{u} --oneline
7edead8 NXP-15160 fixing test class path for redis test-jar
d507b6f NXP-15160 renamed cache component
aaf64ab NXP-15161 re-worked redis feature activation
23b1d2c NXP-15254: use concurrent hash maps to avoid locks on service access
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.