guy mograbi guy mograbi - 20 days ago 7
Git Question

How to use a commit in git without adding it to your branch?

I have branch X - working on a task.
Suddenly I run into a bug, and I fix it on branch Y and open a pull request.

I would like to continue work on branch X, with the changes made on branch Y but without the commit.

Is there a way to do this in git?

Answer

You could cherry-pick the commit on branch Y to branch X, and tell it not to make a commit.

git cherry-pick <hash> --no-commit

Comments