Some git commands to practice

Here are few git commands to practice. And don’t forgot to edit github source by hitting DOT (.)!

*Stashing
git stash                             #changes to default stash
git stash pop                         #put back default stash

git stash save 'change description 1' #changes to labeled stash
git stash list                        #list all stashes
git stash apply 0                     #put back stash listed with index 0

*Three ways to add changes
git commit -a
git commit -am "describe here"

git add dir1/file1
git status
git reset

git add -p #prompt to all small changes

*Push more explicitly
git push origin my_branch --set-upstream #if for the first time

*Undoing commit
git commit -m "change 1 description"
git reset --soft HEAD~1               #commit undone

*Stash between branches
git stash                   #changes to default stash in current branch           
git checkout -b new_branch
git stash pop               #put back default stash to new_branch

*Log
git log --oneline
git log --graph

*
git commit --amend -m "new message"
git log
git revert f252a4ccee329c60fd8c01ae216c6e48f857a482

*$ git log
commit f252a4ccee329c60fd8c01ae216c6e48f857a482 (HEAD -> master)
Author: User <user@gmail.com>
Date:   Thu Sep 29 08:34:45 2022 -0500

    PROJECT 2022-0929

commit 201fbe8333be0640b2b606128b5d2195bdc8866c
Author: User <user@gmail.com>
Date:   Wed Sep 28 18:50:35 2022 -0500

    PROJECT 2022-0928

commit 49eca59f883b96eb92fa51552cdc36672a2c2ceb
Author: User <user@gmail.com>
Date:   Mon Sep 26 21:30:14 2022 -0500

    PROJECT 2022-0927
This entry was posted in workday. Bookmark the permalink.

Leave a Reply