Git Interview Questions
Git is a tool for keeping track of changes in computer programs. It’s free to use and lots of people in the software field use it. Now, …
git cherry-pick
is useful command to pick specific commit or multiple commits from another branch and merge it to another branch(or we can say that your current branch)Usage:
$ git cherry-pick <commitHash> <commitHash>
# example
$ git cherry-pick 2fa245 2ba5gvd
For instance, as a frontend developer, you need to do some test with specific endpoint from your backend service. However, let’s assume that specific endpoint has not been added to master branch of the repo. To be able finish your test, you can (temporarly) add the commit(which includes endpoint implementation) into your current frontend-branch using cherry-pick. After you test the endpoint you may remove it. (or create new branch with includes the specific commit, using cherry-pick, then delete the branch, that’s much better)
Let’s do an example. Here is the current branch info: (assume that this is a mono repo - one repo includes both backend and frontend -)
To be able test the endpoint you can run the following commands:
$ git checkout frontend-branch
$ git cherry-pick f
After these commands here is the frontend-branch:
Git is a tool for keeping track of changes in computer programs. It’s free to use and lots of people in the software field use it. Now, …
In this long blog, we are going to improve our git knowledge. I will try to explain the some concepts behing the basic things in git. Writing perfect …