Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the parent of a specific commit in Git

Tags:

git

I have a commit number. I would like to get the previous commit number (parent). I need commits from the current branch.

like image 522
MPAW Avatar asked May 22 '17 12:05

MPAW


People also ask

How do I pull only a specific commit?

Go to either the git log or the GitHub UI and grab the unique commit hashes for each of the commits that you want. "Cherry pick" the commits you want into this branch. Run this command: git cherry-pick super-long-hash-here . That will pull just this commit into your current branch.

How do I find a specific commit in git?

If you have the hash for a commit, you can use the git show command to display the changes for that single commit. The output is identical to each individual commit when using git log -p .

What is parent commit?

The parent commit is the commit this current commit is based on. Usually: When you git commit normally, the current commit becomes the parent commit of the new commit that's introduced by the command.

How do I find a list of file changes in a specific commit?

Find what file changed in a commit To find out which files changed in a given commit, use the git log --raw command. It's the fastest and simplest way to get insight into which files a commit affects.


1 Answers

git log --pretty=%P -n 1 "$commit_from" 
like image 100
MPAW Avatar answered Oct 09 '22 07:10

MPAW