Git Survival Kit - Part 2

farhadf

Farhad F.

Posted on January 11, 2022

Git Survival Kit - Part 2

This is the second part of my git survival kit series, a collection of easy-to-learn and vital commands for day-to-day git operations for everyone. Even if you're new to git, knowing these commands will definitely help you become more productive and solve your mistakes.

1. display the list of branches

local branches: git branch

remote branches: git branch -r

2. display current repository configurations
git config -l

3. delete tag from the local repository
git tag --delete tagname

4. delete tag from the remote repository
git push --delete origin tagname

5. see which commit a tag points to
git rev-parse tagname

6. revert branch history to a specific tag, discarding all changes after the tag
git reset --hard tagname

7. revert branch history to a specific tag, keeping all changes after the tag in the staging area
git reset --soft tagname

8. filtering history of commits in date ranges using since and until options
git log --since='yesterday'
and
git log --since="1 week ago" --until="yesterday"

9. showing commit history with summary of changes made in each commit
git whatchanged

also, the since and until options can be used to filter history

git whatchanged --since='2 weeks ago' --until='2 days ago'

10. see the changes to a file in a commit
git show commit_hash -- file_name

💖 💪 🙅 🚩
farhadf
Farhad F.

Posted on January 11, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Git Survival Kit - Part 1
git Git Survival Kit - Part 1

January 10, 2022

Git Survival Kit - Part 2
git Git Survival Kit - Part 2

January 11, 2022