Mithun Shreevatsa
Mithun Shreevatsa

Reputation: 3609

Can we git undo committed files from the folder towards the destination branch?

Due to pre-commit hooks configured for lint, accidentally committed some unwanted files which just has alignment fixes towards destination branch.

This has changed a lot of files majorly .json files, can we revert the file change. We noticed these changes bit later, so hence we can't even ammend now. Is there any chance to undo this file changes especially .json inside some folders towards the destination branch?

Upvotes: 0

Views: 52

Answers (2)

mahesh
mahesh

Reputation: 26

Lets say PR is raised from Branch "A" to branch "B"

You can replace the folder in your local workspace from branch B doing the following

git checkout B com/test/src/main/resources

Then do a git add and git push origin to branch A.

After the above steps you will not see the files under resources in the PR diff anymore

Upvotes: 1

danirod
danirod

Reputation: 350

If the commit cannot be amended because of additional commits being made, it can be interactively rebased.

However, if the affected commits have already been pushed, this may be a difficult task to do, due to synchronization issues if other developers have pulled the affected branch and have done changes on top of the commits that have been modified.

Upvotes: 0

Related Questions