Tag: git

Specify Target File in git cherry-pick

Cherry-picking with git could easily become a nightmare if some files are renamed or the directory structure of the project is changed. In these cases, it is often helpful to cherry-pick the problematic files individually. Fortunately, this can be done in a few easy steps: Create a patch file for that individual file: git show …

Continue reading

Undo a Git Commit on GitHub

In case you’ve pushed an unwanted commit to GitHub (or any upstream Git repository), you can simply undo it. To do so, move the HEAD to the commit that you want to undo to and then run the following command: git push -f origin HEAD^:master

Git: Merge Specific Commit from Another Branch to Main Branch

Let’s say that in your git repository, you have a master branch and an experimental branch. You’ve fixed a bug on file A on the experimental branch and you would like to commit that fix to the master branch. This is possible using the git cherry-pick command. First, switch to the experimental branch and execute git log. Take …

Continue reading