0% found this document useful (0 votes)
50 views

Git Commands

Git commands for cherry picking commits, checking the current branch, checking out files from previous commits, cloning repositories with submodules, changing author information and squashing commits. Key commands include git cherry-pick, git log --first-parent, git checkout, git clone --recurse-submodules, git commit --amend, git rebase -i, and git push --force.

Uploaded by

manojsingh474
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

Git Commands

Git commands for cherry picking commits, checking the current branch, checking out files from previous commits, cloning repositories with submodules, changing author information and squashing commits. Key commands include git cherry-pick, git log --first-parent, git checkout, git clone --recurse-submodules, git commit --amend, git rebase -i, and git push --force.

Uploaded by

manojsingh474
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

To cherry-pick a commit

git cherry-pick <commit-hash>

to check on which branch you are if confused


git log --first-parent ---> this shows the parent brnach

to checkout a particular file in a commit


git checkout <previous commit id> -- filename

to clone the repo


git clone --recurse-submodules ssh://git@bitbucket-il:7999/p5g/cu.git CU

if you didn't use --recurse-submodules then do the following


git pull --recurse-submodule
git submodule update --init
git submodule update --recursive –remote

to change the git config:


1. git config --global user.name "Sam Smith"
2. git config --global user.email [email protected]
3. git config --local user.name "Sam Smith"
4. git config --local user.email [email protected]

to revert a commit
git revert <commit hash> and then git push will do it

To change author of existing commit


git commit --amend --author="Author Name <[email protected]>"
git commit --amend --author="Mayuri Patil <[email protected]>"

git branch -d 19_00_271_1_70_build -- to delete local branch

How to squash the commit?


=====================
1.git rebase -i HEAD~2 (2 means top 2 commit we want to merge)
2.Then editor will be opened in that first one will be latest commit. For all
subsquent commit right squash.
3.Save and close
4.The next file will be opened there Edit the commit message
5.Save and close.
6.Do git push --force.

You might also like