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