Git
Staging files
add
addAdding files to stage (add)
add)git add .git add file1.ts file2.ts ...Adding and Removing multiple files to stage (add -i)
add -i)git add -iTo select changes in a file, and commit them separatly (add -p)
add -p)Useful when you made multiple changes in the same file, but want to make different commits for some of the changes.reset
resetRemoving files from stage (reset)
reset)diff
diffTo see what is changed in the staging area (diff --staged)
diff --staged)Commiting
commit
commitCreate commit (commit)
commit)commit -S
commit -Scommit --amend
commit --amendreset
resetFixing several un-pushed commits (reset)
reset)--hard reset
--hard reset--soft reset
--soft resetrebase
rebaseFixing several un-pushed commits (rebase)
rebase)Options
Description
Logging
log
logShow commit logs from the current branch (log)
log)Show logs formatted in a one line
Show logs with GPG signatures
Show only last n logs
n logsBranches
branch
branchCreating branches with (branch)
branch)Deleting branches with (branch -D)
branch -D)checkout
checkoutCreate branches and checkout to them with (checkout -b)
checkout -b)Tagging
tag
tagCreate annotated tags with (tag)
tag)Create lightweight tags with (tag)
lightweight tags with (tag)Create tags to specific commits with (tag)
tag)Delete tags
Save Uncommited Work
stash
stashStash work in a branch with (stash)
stash)To unstash the work with (stash pop)
stash pop)To list the WIP (Work in Progress) stashes
diff
diffSave work done to a .patch file with (diff)
.patch file with (diff)Apply .patch file to working branch with (apply)
.patch file to working branch with (apply)Garbage Collector
Rewriting git commit history (BFG Repo-Cleaner)
BFG Repo-Cleaner)Dealing with large files (lfs)
lfs)To deal with this use lfs
lfsLast updated