I have a feature branch feature-1-branch
created from master.
A lot of time as passed and I created a lot of commits on feature-1-branch
.
Now I want to revert commit all changes in a specific directory, lets say src/modules/feature-2
I made in branch feature-1-branch
back to the state as they are in master
.
Im sure this must be possible in git, just not sure how to do it!?
In order to revert the last Git commit, use the “git revert” and specify the commit to be reverted which is “HEAD” for the last commit of your history.
How would I revert just the current directory in Git? Use git checkout instead of reset. git checkout <branchname>~1 -- path/to/directory/you/want/updated should do the trick.
Commit the changes, reusing the old commit message. reset copied the old head to . git/ORIG_HEAD ; commit with -c ORIG_HEAD will open an editor, which initially contains the log message from the old commit and allows you to edit it. If you do not need to edit the message, you could use the -C option.
Just checkout src/modules/feature-2 directory from feature-1
branch to origin/master
branch.
$ git checkout feature-1-branch
$ git fetch
$ git checkout origin/master src/modules/feature-2/
Now, You have identical src/modules/feature-2 directory in both master
and feature-1-branch
branch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With