2

I have the following list of commits:

a->b->c->d->e->f where letters would represent the sha hash. If commit c breaks the build I want new structure to look like this a->b where everything else on the branch would be deleted. I am working in a headless state, and it seems like BitBucket REST API doesn't provide rest calls to handle it in headless state, so would have to do git operations in some other environment so all my work has to be relative to commit c, because its the only information that I will know. I know most likely I would have to use rebase, but I wasn't sure how to git operations relative to the sha number. Thanks for your help!

Dzerlig
  • 247
  • 2
  • 10

1 Answers1

1

From the command-line, you can do the following:

git checkout <branch>
git reset --hard b
git push -f

Note this assumes that you clone the repo locally. If you need help with that, google "git clone".

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
  • How would I determine what hash is b? Is there a way to reset relative to c, something like c-1? – Dzerlig Aug 15 '18 at 20:31
  • @Dzerlig `git log` is the primary command to find information about commits. `git log --oneline` gives the output in a shortened format. You can refer to the parent of a commit with `~`. For example, `git reset --hard c~` assuming you know the SHA hash for commit `c`. To learn more about git concepts and commands, I suggest you read the first three chapters of [Pro Git](https://git-scm.com/book/en/v2). – Code-Apprentice Aug 15 '18 at 20:47