How To Find a Git Commit ID in Branches and Merges

Author: , February 7th, 2020

First, get on the branch that you know already has the commits you are looking for:

Copy-and-paste the commit(s) you want:

~or~

Optionally, display the code changes for a visual confirmation:

Finally, extract the list of branches that contain the desired commits:

Example:

How To Show the Origin in Git

Author: , January 30th, 2020

Recently, I wanted to see the “origin” of the git repository I was working in. The command is: git remote -v For example:

How To Change Your Commit Message in Git

Author: , December 2nd, 2019

Not pushed + most recent commit:

How To Show Filenames With git log

Author: , June 3rd, 2019

To display the filenames included in each commit, just add the –name-only argument to git log:

How To Remove A File From The git Staging Pre-Commit List

Author: , May 31st, 2019

Quickref: How to Remove a file from the staging area

The Story Recently, I accidentally added some files to git’s pre-commit phase, i.e.:

For example, here is how to handle the above situation:

To better understand, here are the phases/states/stages that git uses: Untracked – when a file is first created, git […]

How To Revert a Single File to a Specific Commit Using git

Author: , March 18th, 2019

~or~

How To Revert All Changes in a git Branch

Author: , August 2nd, 2018

git checkout -f

How To Rename a Branch in Git Locally and Remotely

Author: , January 31st, 2018

Rename the old branch locally: git branch -m oldBranch newBranch Delete the old branch remotely: git push origin :oldBranch Push up the new branch, and make the local branch track with the new remote branch: git push –set-upstream origin newBranch

How to Manage Remote Branches in Git

Author: , October 19th, 2017

Git does not download all branches unless you tell it to. Until then, they are ‘remote’ branches. Use -r to list remote branches: git branch -r git fetch –all git pull –all If you see this error: fatal: The current branch CT-37 has no upstream branch. Push the current branch and set the remote as […]

How To Revert a Single File in Git to Match the Master Branch

Author: , October 19th, 2017

If you want to revert the file to its state in master: git checkout origin/master [filename]