Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit » Unstaging changes during a merge(Potential dangerous behavior)
Unstaging changes during a merge [message #929824] Mon, 01 October 2012 16:16 Go to next message
Matt McClellan is currently offline Matt McClellan
Messages: 2
Registered: October 2012
Junior Member
My organization ran into a problem a few weeks ago where some code went missing during a merge of someones local repo with that of the remote.

We found that what had happened was the user had unstaged all the files that were merged using the egit staging tool, and then staged just the conflicted file, committed, and pushed. It shows no history of him doing it in git but afterwards, and using diff you can see he effectively undid all the work that had been committed on remote since his last pull.

From what I can tell git does not allow you to unstage merged files during a conflict but egit (or jgit) will let you. I'm not a git expert so I was wondering if this is expected behavior. Whether it is or not is there is a way we can block users from doing this? Aside from throwing them out the window Smile
Re: Unstaging changes during a merge [message #929876 is a reply to message #929824] Mon, 01 October 2012 17:12 Go to previous messageGo to next message
Matt McClellan is currently offline Matt McClellan
Messages: 2
Registered: October 2012
Junior Member
We have found that you can also do this from command line using `git add -i` and then reverting a file.
Re: Unstaging changes during a merge [message #930403 is a reply to message #929876] Tue, 02 October 2012 05:25 Go to previous message
Christian Halstrick is currently offline Christian Halstrick
Messages: 99
Registered: July 2009
Member
When you unstage something in the EGit staging view then what happens is similar to a native git 'git reset <filename>'. And native git of course allows you to do that also on already merged files. We really need this option. The way how you solve conflicts may influence your decision whether you want merged file content on other files or not.

Here is how you unstage with native git:

git init
echo -e 'line1\nline2\nline3' > a
echo -e 'line1\nline2\nline3' > b
git add a b
git commit -m "adding a,b"
git checkout -b side
echo -e 'line1\nline2(side)\nline3' > a
echo -e 'line1\nline2\nline3(side)' > b
git commit -a -m "modifying a,b on side"
git checkout master
echo -e 'line1\nline2(master)\nline3' > a
echo -e 'line1(master)\nline2\nline3' > b
git commit -a -m "modifying a,b on master"
git merge side
echo -e 'line1\nline2(combined)\nline3' > a
git reset b




Ciao
Chris
Previous Topic:Bogus syntax complaint
Next Topic:Creating a new file ending in .orig.
Goto Forum:
  


Current Time: Fri Jul 25 16:01:45 EDT 2014

Powered by FUDForum. Page generated in 0.10781 seconds