0

I have some code that I've been working on and I've changed 4 files.

However during the setup process there were several files changed that I was unaware of.
Then I did a git add . and pull a 22 more files into the commit without realizing it.

Now 3 commits later on the branch I want to submit a merge request but I'd like to remove the 22 files that the setup changed.

I'm thinking it'd work something like this: switch back to the master branch and create a MergeRequest branch.

Merge the merge request branch with the work branch and cherry pick the files that I want. Is this the best way of handling this issue?

2 Answers 2

1

I would prefer to fix this closer to the source of the problem. Create a branch "fix" on the commit before the problem commit. Cherry-pick the problem commit onto that branch, committing only the files you meant to commit. Then rebase the other commits from your branch onto fix:

git rebase --onto fix < bad commit > < original branch>

Only when things are cleaned up on your branch do you submit a merge request.

Sign up to request clarification or add additional context in comments.

Comments

0

git reset --hard will take to the previous state.

Use the git reflog command to find the SHA-1 of the previous state and then reset to it.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.