Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #### git is awesome! Will do some live demos.<br/>Bring your problems, I'll try to solve them!
- ---
- # Yep, `git`.
- ---
- ## I am @jacquesbh
- ### Magento Firefighter
- ### Tools lover
- ### Founder of @MonsieurBiz
- ### Board member of the French PHP Group "AFUP"
- ---
- # What is git?
- ---
- # `git` is a Version Control System
- ---
- # That's it?
- ---
- # [fit] NOPE.
- ---
- # `git` is:
- * A tree, with branches
- * A logger
- * A cloner
- * A conflicts recorder
- * A crazy tool
- * A "doer" for many things…
- ---
- # With `git` you can really do more than you think.
- ---
- ## We're going to use:
- * The Command Line
- * and SourceTree (because it's easier)
- ---
- ```
- man git
- …
- git-cherry-pick(1)
- Apply the changes introduced by some existing commits.
- git-citool(1)
- Graphical alternative to git-commit.
- git-clean(1)
- Remove untracked files from the working tree.
- git-clone(1)
- Clone a repository into a new directory.
- …
- ```
- ---
- # [fit] `git log`
- ---
- ###### demo
- Basics:
- ```bash
- $ git log
- commit 2af6081e23531d11a19c6a2f707f26835b9ac37f
- Author: Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com>
- Date: Fri Feb 3 16:18:07 2017 -0500
- magic, have no clue but it works
- Notes:
- Yep, this is a note.
- commit bb21d532a06aab4631ddb9d26b421ec390c953a8
- Author: Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com>
- Date: Fri Feb 3 16:05:13 2017 -0500
- magic, have no clue but it works
- ```
- ---
- When you sign your commits:
- ```bash
- $ git log --show-signature
- commit 2af6081e23531d11a19c6a2f707f26835b9ac37f
- gpg: Signature made Fri Feb 3 16:18:07 2017 EST
- gpg: using RSA key CD2C5D48C181EBE4
- gpg: Good signature from "Jacques Bodin-Hullin <jacques@bodin-hullin.net>" [unknown]
- gpg: aka "Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com>" [unknown]
- gpg: WARNING: This key is not certified with a trusted signature!
- gpg: There is no indication that the signature belongs to the owner.
- Primary key fingerprint: DEB8 A04A 7CB9 5FD7 57E8 B1A0 5B80 3023 D40A 0F67
- Subkey fingerprint: 8A45 FB3F 7E49 DE2F 907F E174 CD2C 5D48 C181 EBE4
- Author: Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com>
- Date: Fri Feb 3 16:18:07 2017 -0500
- magic, have no clue but it works
- Notes:
- Yep, this is a note.
- ```
- ---
- ### What about a more complex log? Like a tree?
- ```
- $ git log --graph --all --format=format:'%C(bold blue)%h%C(reset) \
- - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) \
- %C(bold white)- %an%C(reset)%C(bold yellow)%d%C(reset)' \
- --abbrev-commit --date=relative --color=always -15
- ```
- ---
- # [fit] `git rebase -i`
- ---
- ###### demo
- ```bash
- $ git checkout foo
- ```
- Then add commits and perform a rebase on `origin/foo`.
- ---
- # [fit] `git cherry-pick`
- ---
- ###### demo
- ```bash
- $ git cherry-pick 1bf6d18dd
- [cherry-pick dbe74eb] Useful text
- Date: Fri Feb 3 16:04:36 2017 -0500
- 1 file changed, 1 insertion(+)
- create mode 100644 file8.txt
- ```
- ---
- ## What happen if I rebase a branch on another with some identical commits?
- The duplicated commits disappear!
- ---
- # [fit] `git worktree`
- ---
- ###### demo
- ```bash
- $ git worktree add ../fix-stuff
- ```
- ---
- # [fit] `git reflog`
- ---
- ###### demo
- ```bash
- $ git reflog
- 5098179 HEAD@{0}: reset: moving to master
- 977f91e HEAD@{1}: checkout: moving from cherry-pick to cherry-pick2
- 5098179 HEAD@{2}: reset: moving to master
- 977f91e HEAD@{3}: rebase finished: returning to refs/heads/cherry-pick
- 977f91e HEAD@{4}: rebase: checkout cherry-pick2
- 70dcd89 HEAD@{5}: reset: moving to HEAD
- 70dcd89 HEAD@{6}: cherry-pick: It compiles! Ship it!
- 5098179 HEAD@{7}: checkout: moving from cherry-pick2 to cherry-pick
- ```
- ---
- # [fit] `git clean`
- ---
- ###### demo
- ```
- $ git clean -i
- Would remove the following items:
- file30.txt file31.txt file32.txt file33.txt
- *** Commands ***
- 1: clean 2: filter by pattern 3: select by numbers 4: ask each 5: quit 6: help
- What now> 4
- Remove file30.txt [y/N]?
- Remove file31.txt [y/N]?
- Remove file32.txt [y/N]? y
- Remove file33.txt [y/N]?
- Removing file32.txt
- ```
- ---
- ```
- $ git clean -df
- ```
- ---
- # [fit] `git bisect`
- ---
- ###### demo
- ```bash
- $ g bisect bad
- 2c0d770dda8ce3b00c1756a09cacc6677fcc238b is the first bad commit
- commit 2c0d770dda8ce3b00c1756a09cacc6677fcc238b
- Author: Jacques Bodin-Hullin <j.bodinhullin@monsieurbiz.com>
- Date: Fri Feb 3 16:58:32 2017 -0500
- MOAR BIFURCATION
- :100644 100644 39bf59e13… 8d94e8e37f… M index.php
- ```
- ---
- # [fit] `git notes`
- ---
- ###### demo
- ```bash
- $ git notes add -m "CI PASS"
- $ git push origin refs/notes/commits
- ```
- ---
- # [fit] `git remote prune origin`
- ---
- ###### demo
- ```bash
- $ git remote prune origin
- Pruning origin
- URL: git@github.com:monsieurbiz/talk-git-sunphp17.git
- * [pruned] origin/bob
- ```
- ---
- # [fit] `git check-ignore`
- ---
- ###### demo
- ```bash
- $ echo file100.txt > .gitignore
- $ # …
- $ git check-ignore *
- file100.txt
- ```
- ---
- # [fit] `git rerere`
- ---
- ### Usually when "control MERGE"
- ```bash
- $ git config --global rerere.enabled true
- ```
- ---
- # Tip: aliases!
- ---
- ### Some of mine…
- ```bash
- $ git br
- $ git tr
- $ git ci
- $ git cp
- $ git cn
- $ git rb
- $ git rod
- $ git rodd
- ```
- ---
- # Tip: `tig`
- ---
- # What about your problems?
- * `log`, `rebase`
- * `cherry-pick`, `worktree`
- * `reflog`, `clean`
- * `bisect`, `notes`
- * `remote prune`, `check-ignore`
- * `rerere` and `tig`
- ---
- # [fit] Thanks!
- ---
- ## How to sign your commit?
- ```
- $ git config --global commit.gpgsign true
- $ git config --global user.signingkey D40A4467
- ```
- ---
- # You can change the GPG programm too
- ```
- $ git config --global gpg.program /Users/jacques/bin/git/gpg
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement