DEV Community

Farhad F.
Farhad F.

Posted on

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

Top comments (1)

Collapse
 
dinniej profile image
Nguyen Ngoc Dat

This is great. Nice if you can include the git cherry-pick command. This command saved me so many time when I need to do some testing with a project include many modules update. Still missing some essentials like rebase, stash, checkout tho. Great article btw