0

I recently did a freelance assignment from the master branch of my customer's project by mistake. I assured him that I could move my work to an entirely different branch and return master to the original commit I started from.

I already checked out a new branch (via git checkout -b NewBranch) But between reset revert and cherry-pick it's not clear to me which command best suits my needs.

Specifically, I want to make it look like the master branch was never touched. I'm afraid of rolling back to a previous commit on master and losing the commits on NewBranch Note: none of my commits have been pushed

degenPenguin
  • 725
  • 1
  • 8
  • 23
  • As long as the code has been committed you will have little reason to worry about data loss. If you're worried you can create "backup branches' which will prevent the commit from being deleted by accident (which is already very unlikely). – evolutionxbox May 01 '21 at 22:04
  • 1
    Just reset your local master to orgin’s master. Sounds like you’re newBranch is good to go. – JBallin May 01 '21 at 22:10
  • 3
    Yup, see https://stackoverflow.com/questions/3528245/whats-the-difference-between-git-reset-mixed-soft-and-hard/59675191?r=SearchResults&s=1%7C33.8176#59675191. This is regret Type 3. – matt May 01 '21 at 22:11
  • Does this answer your question? [Need to reset git branch to origin version](https://stackoverflow.com/questions/9301782/need-to-reset-git-branch-to-origin-version) – evolutionxbox May 01 '21 at 22:11
  • Confused. Did you push to `master` or not? The title suggest no but the body suggests yes – astrochun May 01 '21 at 22:20
  • @matt that explanation is gold. i appreciate all the replies – degenPenguin May 01 '21 at 23:08

0 Answers0