Git Class Note
Git Class Note
git --version
git help
Configuration
git init
1/5
Get the content of a remote repo
git status
Stage files
At this point you're free to make changes, create new commits, switch branches, and perform any other
Git operations; then come back and re-apply your stash when you're ready.
git stash
git stash list
git stash pop
git stash apply <stash>
git stash clear
git stash drop <stash>
Commit
git commit
git commit -m “message”
git commit -am “message”
git commit --amend
2/5
git log
git log --oneline
git log --since=<date>
git log --since=2.weeks
git log --since="2008-01-15"
git log --since="2 years 1 day 3 minutes"
git log --until=<date>
git log -- <file>
git diff
Clean
git rm
git rm --cached
git checkout
Branches
Rename the current branch
Switch to a branch
3/5
Create and switch to a branch
Use -D instead if you want to force the branch to be deleted, even if it hasn't been pushed or merged
yet.
See branches
git branch
git branch -r
git branch -a
git merge
Remote Ops
Connect to remote repo
git fetch
git pull
4/5
git push -u origin master/main
git push
gitignore
A good documentation about gitignore
5/5