introduction
Git history
What is a commit
Git local workflow
Commit history
The time machine
What do rebase
Stash what you can't finish
Tag / Cherry-pick / Diff
Linus Torvalds
Source
Modify file ->
Declare modification of the file ->
Give context on modification ->
Save modification
- Working directory
- Staging
git add <new files>
git add -u
add all modified file to staging
git add -p
Will select lines modifications from files (help crafting atomic commit)
git add test*.ts
Will add all files prefixed by test and finishing by .ts to staging
git add -A
Will add everything pending in your working directory into staging
git add *
git commit -m 'feat(photo): blablabla'
git commit -m 'blabla'
Create commit with message blabla and file staged
git commmit -m 'blabla' --allow-empty
Create commit with message blabla and no modifications from staging
git commit --amend
Will add to previous commit staged files and allow you to edit it's message
git commmit -am "blabla"
Will add all modifications (not new files) pending in your working directory into staging and create a commit with it
git status
display actual working directory and staged files or both modified files
git diff
diff between working directory and staged files
git show
<SHA-1 commit|tag|blob>
Display message + diff of commit | tag details + commit SHA-1 related id | content of a blob
diff between staged file and HEAD
git diff --staged
git reset
Will allow you to reset your git repository to a specific state ( and decide to keep or not diff between current state and reset state)
git checkout
<branch |commit|tag >
Move your HEAD to specific commit or tag or branch (lot of options)
Git project modification historic
Contain all the commits made on all branch and is able to display it through graph
gog='git log --pretty=tformat:'\''%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'\'' --branches --graph'
You can move back in time if needed thank to HEAD
HEAD is a pointer which can move through git objects
Create a new commit with your fix
git reset --soft HEAD^
git reset --soft HEAD~1
git commit --amend
Shit i made a mistake in my previous commit
i pulled branch and failed a merge conflict which i validated
git reflog