Copying commits from a branch to another
Let say we made some changes and committed them in the wrong branch and we want to move or just copy it to the current branch - we do that using cherry-pick command.
The first we need to find the commit ID which we can do by using the log command. A list of commits will be shown:
$ git log <source branch>
Now, in the current branch, we run the follow command:
$ git cherry-pick c61c5e4
Copying only a file from a commit to another branch
$ git checkout <commit> <folder or file path in the current branch>
Retoring a file from a branch
$ git checkout <branch> <file path in the current branch>
Let say we made some changes and committed them in the wrong branch and we want to move or just copy it to the current branch - we do that using cherry-pick command.
The first we need to find the commit ID which we can do by using the log command. A list of commits will be shown:
$ git log <source branch>
Quote:commit c61c5e42edbc31f49bf3dd373e564dd3742b0d79We need to take note of the only first seven number: c61c5e4
Author: user <user@mail.com>
Date: Wed Oct 28 18:06:42 2015 -0200
Fixed .auv file parser for menu option control
...
Now, in the current branch, we run the follow command:
$ git cherry-pick c61c5e4
Quote:[mv/shaders f2af162] Fixed .auv file parser for menu option controlDone!
1 file changed, 10 insertions(+), 1 deletion(-)
Copying only a file from a commit to another branch
$ git checkout <commit> <folder or file path in the current branch>
Retoring a file from a branch
$ git checkout <branch> <file path in the current branch>