GIT
introduction
Who know about Git?
Who is confortable undoing a mistake in git?
What i'm gonna talk about?
-
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
- External resources
Git history
Linus Torvalds
Source
Git definition
- Decentralized ( repo clone localy)
- File system manager
- Two datastructure
- mutable index for working directory and staging
- database which can contain 5 objects
- blob (binary large object)
- tag
- tree
- commit
- packfile (gzip=compressed version of other items)
What is a commit
It's a snapshot of files modifications
Git local workflow
Modify file ->
Declare modification of the file ->
Give context on modification ->
Save modification
Simple dev workflow
- Working directory
- Staging
Simple dev workflow
File status
Simple dev workflow
git add <new files>
Git add good to know options
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 good to know options
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
Main git actions
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
Main git actions
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 log
Git log
Git project modification historic
Git log important notions
Contain all the commits made on all branch and is able to display it through graph
- Each commit can have only one parent commit
- A tag can point toward a commit
- A branch name is a specific tag always at the tip of a branch
gog='git log --pretty=tformat:'\''%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'\'' --branches --graph'
The time machine
Git log know when you are
You can move back in time if needed thank to HEAD
HEAD is a pointer which can move through git objects
Edit the past
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
Undo the present
i pulled branch and failed a merge conflict which i validated
git reflog
- Each git action has it's own SHA-1 identifier
- Use git reset --<soft|mixed|keep|hard> <SHA-1 number>
- Git is now back to this last action
What do rebase
<WIP>
So let's demo
Stash what you can't finish
<WIP>
So let's demo
Tag / Cherry-pick / Diff
<WIP>
So let's demo
Resources
<WIP>
i will add them!
Thanks for you time
Git
By ben080989
Git
- 41