Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 347951

Summary: [server] Need "git reset --hard origin/master" API on server
Product: [ECD] Orion Reporter: libing wang <libingw>
Component: GitAssignee: Tomasz Zarna <tomasz.zarna>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Szymon.Brandys
Version: 0.2Flags: Szymon.Brandys: review+
Target Milestone: 0.2   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on:    
Bug Blocks: 347953, 348579    

Description libing wang CLA 2011-06-01 10:33:41 EDT
In bug 343963 , I mentioned "git reset --hard HEAD" but this does not really undo the last commit.
"git reset --hard HEAD" will just checkout everything but in the case of complicated conflicts happen we just want to undo the last commit and pull again.
I will keep the solution from bug 343963 for a feature "checkout all"
Comment 1 Tomasz Zarna CLA 2011-06-06 05:21:59 EDT
Why would you like to do such thing? If you want to replace your current branch with changes from a remote branch and discard any commits you made locally (which may lead to a conflict) "git reset --hard HEAD^" is not the best option. There might be more than one local commit you need to reset so you would either execute "git reset --hard HEAD^" multiple times or look for something like "git reset --hard HEAD~3"

A better approach would be to reset your current branch to the remote branch e.g. "git reset --hard origin/master".
Comment 2 libing wang CLA 2011-06-06 09:57:05 EDT
(In reply to comment #1)
> Why would you like to do such thing? If you want to replace your current branch
> with changes from a remote branch and discard any commits you made locally
> (which may lead to a conflict) "git reset --hard HEAD^" is not the best option.
> There might be more than one local commit you need to reset so you would either
> execute "git reset --hard HEAD^" multiple times or look for something like "git
> reset --hard HEAD~3"
> 
> A better approach would be to reset your current branch to the remote branch
> e.g. "git reset --hard origin/master".

"git reset --hard HEAD^" was just an experimental solution when I hit a the conflicting case.The only solution I knew at the moment was to use "git reset --hard HEAD^" and pull again.
Of course if "git reset --hard origin/master" is a better approach I would love to use that .
Comment 3 Tomasz Zarna CLA 2011-06-07 06:17:25 EDT
Another option could be allowing to select a commit on Git Log page and hard reset to it: "git reset --hard {selected commit}". However, to make this approach useful when merging branches we would need to fix bug 343644 first.
Comment 4 Tomasz Zarna CLA 2011-06-07 10:31:34 EDT
Fixed with http://git.eclipse.org/c/e4/org.eclipse.orion.server.git/commit/?id=b9e7f2e45e8b29e063fb27e36e17fa8044c42f00. You can now reset the current branch to a given commit doing a POST on /git/index/... and adding a "Commit": "{commit}" (eg. "origin/master") parameter in the request body.