http://www.cnblogs.com/wavky/p/3504060.html
稍微總結下弄了半個下午的egit的merge合並沖突解決方法,網上看的都是一個模板出來的,看的糊里糊塗,花了很多時間去實驗整個合並流程..
前提工作
- 創建一個普通JAVA工程Test,創建一個類Test,寫點東西並加入到本地git庫;
- 創建個develop分支,創建個Develop類,修改Test類的某些語句,添加新代碼段,提交;
- 切換到master分支,創建個Master類,修改Test類的同一部分語句,提交;
以上三條操作不進行詳細說明,很簡單的。
合並過程
打開git repository exploring視圖:
在Test庫中,在develop分支上打開右鍵菜單,點擊Merge:
出現沖突提示框:
返回JAVA工程項目視圖,可以看見Test工程已經自動進行了部分合並,添加了Develop類,但Test類存在沖突(有紅色雙箭頭標記的文件才是沖突,茶色星星標記的文件沒有實際沖突項),選中工程打開右鍵菜單,打開Merge Tool:
Merge Tool界面顯示如下,左邊為沖突文件的當前版本(master分支),右邊為准備合並過來的目標版本(develop分支),手工把右邊的代碼copy到左邊,或至少隨意更改下左邊的文件,保存。 注:右邊的窗口有時候標題顯示的版本節點不正確,可能是BUG,或者筆主理解能力不足所致。
在Merge Tool中更改並保存后,當前沖突的Test類如下圖中的各種神奇標記符號將自動消除:
上圖的紅色神奇符號已經自動合並消除,並呈現類似下圖的合並效果:
Window->Show View->Other,打開Git Staging視圖:
Git Staging視圖中,Unstaged Changes部分包含沖突文件(包括手工合並前后),Staged Changes部分包含已經完成自動合並的文件,在已經合並完成的沖突文件Test.java上打開右鍵菜單,選中Add to Git Index:
Test.java被添加到Staged Changes下面,並自動生成Commit Message等內容,確認無誤后點擊Commit提交:
至此,Merge合並的沖突已經完全解決,從develop到master方向的合並已經完成:
若要從master合並到develop,只需切換到develop分支,(在git repository exploring視圖中)在master菜單上點擊Merge即可。筆主使用的Egit2.2版本默認進行Fast-Forward方式的合並,最新的3.2版已經提供是否選擇Fast-Forward的UI窗口。
* 關於Egit3.2的Fast-Forward合並:提供該選擇的UI窗口僅在JAVA視圖窗口中,通過項目工程右鍵菜單中執行Team->Merge觸發顯示,通過上面使用git repository exploring視圖簡單調用Merge的方式仍然使用默認的Fast-Forward合並:
==============================================
https://allaboutmynonexistedworld.wordpress.com/2014/02/05/eclipse-git-merging-branch-to-master/
1. Make sure the current pointer is at master.
2. Right click on the project to be merged. Select Team -> Merge
3. In the pop up window, double click on the branch you want to merge.
4. A merge conflict window should jump up. Click OK to continue
5. Right click on the project with a red mark. Select Team -> Merge Tool
6. In “Select a Merge Mode” window, select Use HEAD option and hit OK
7. Edit it in the editor however you want (play around with the options)
8. Once you decided the conflict is resolved, right click on the red mark file, select Team -> Add to Index
9. Finally, you should be able to commit the changes and push to the upstream.
===========================
Problem resolve “egit remote tracking show nothing”
有時候在用Team => Switch to => 時, 看不到想要的branch, 用如下方法解決.
How do I get a new branch to show up in Eclipse Git Remote Tracking?
I have an existing Eclipse git project, with a master and development branch present in both local, and remote tracking. I have just added a new branch in my git repository, but I can't figure out how to get it to show up in Eclipse.
I have tried to read up on the subject, but it seems like it is just expected to automatically show up. I have found a lot of similar questions, but they all seem to deal with the issues of a completely empty remote tracking folder, instead of my problem of only a single new branch missing. I already have Master and Develop present.
Here is what does not work:
- Clicking refresh in the Git repositories window.
- Any kind of synchronize, pull or other update I can find
Here is what would work:
- Right clicking the remote tracking folder, and selecting "Paste repository path or URI". If I do that, and select the exact same path as is already there, I can see my new branch. This action does require that I completely clone the whole repository to an empty folder again, and that can't be how this is intended to work.
- I believe it might work to use some kind of command line tool, but I really want an Eclipse solution to this, as I feel sure it exists, and I am just missing something.
20
In the Git Repositories view:
- Right-click the repository and choose Fetch from Upstream
- If the new branch will not shown up below Branches/Remote Tracking, you have to configure fetch:
- Right-click the fetch node below Remotes/origin and choose Configure Fetch...
- In the Configure Fetch make sure there is only the single Ref mapping
+refs/heads/*:refs/remotes/origin/*
:
- "No ref to fetch from MyRepository - origin - everything up to date." I'll update my question with screenshots– KjetilNordin Nov 20 '17 at 11:44
- 1
God damnit, in my latest attempts, I just confused two different repositories. So this really does work. Thanks a lot! – KjetilNordin Nov 20 '17 at 11:56
- Make sure that, in the URL field of the above dialog, your fork's URL is shown. – not2savvy Jan 15 at 15:06
add a comment
在執行了一次上面的fetch后, 在用Team => Switch to => 時, 可以看到了branch.