git a starter kit
TRANSCRIPT
![Page 1: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/1.jpg)
Git: a starter kit --++ --++ Boubacar Diallo, Kareea. --++ --++ --++ --++ --++ --++ --++ --++ --
![Page 2: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/2.jpg)
--++ Menu --++ --++ --++ --++ --++ --++ --++ --++ --++ --++ --++ --++
Appetizer
Who knows git? Who uses git?
Main dish
Basic git commands
Dessert
Questions & Answers
![Page 3: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/3.jpg)
What is What is
What is What is What is What is
Git
![Page 4: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/4.jpg)
--++ Not CVS or SVN --++ --++ --++ --++ --++ --++ --++ --++ --++
![Page 5: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/5.jpg)
--++ Distributed RCS --++ --++ --++ --++ --++ --++ --++ --++ --++
![Page 6: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/6.jpg)
--++ What is git? --++ --++ --++ --++ --++ --++ --++ --++ --++ --++
Simple Fast
![Page 7: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/7.jpg)
--++ Getting git --++ --++ --++ --++ --++ --++ --++ --++ --++ --++ --++
Mac: $ brew install git
Linux: $ apt-get install git-core
Windows: msysgit
![Page 8: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/8.jpg)
--++ Setup --++ --++ --++ --++ --++ --++ --++ --++ --++ --++ --++ --++
$ git config --global user.name "Boubacar Diallo"
$ git config --global user.email \ "[email protected]"
$ cat ~/.gitconfig
![Page 9: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/9.jpg)
152Commands
W00T, LOL, OMG, HAXX W00T, LOL, OMG, HAXX
![Page 10: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/10.jpg)
![Page 11: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/11.jpg)
•
![Page 12: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/12.jpg)
•
![Page 13: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/13.jpg)
![Page 14: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/14.jpg)
--++ Basic Usage --++ --++ --++ --++ --++ --++ --++ --++ --++ --++
• Clone existing depot (git clone)
• Initialize git depot (git init)
• Add a file (git add)
• Commit changes (git commit)
• See logs (git log)
• Remove a file (git rm)
• Jump to a commit (git checkout)
![Page 15: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/15.jpg)
--++ Clone existing depot --++ --++ --++ --++ --++ --++ --++ --++
$ git clone <url>
$ git clone [email protected]:username/project.git
Create local depot
Fetch remote master branch with commit history
Save it as local master branch
![Page 16: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/16.jpg)
--++ Make a new project --++ --++ --++ --++ --++ --++ --++ --++
$ cd path/to/repos
$ mkdir project
$ cd project
![Page 17: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/17.jpg)
--++ Initialize git depot --++ --++ --++ --++ --++ --++ --++ --++ --++
$ ls -al # dir is empty
$ git init # initialize git repo
$ ls -al # new .git dir
![Page 18: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/18.jpg)
--++ Working directory --++ --++ --++ --++ --++ --++ --++ --++ --++
Holds current checkout of files you are working on
![Page 19: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/19.jpg)
--++ Index zone --++ --++ --++ --++ --++ --++ --++ --++ --++ --++ --++
Index is used as a staging area between your working dir and your repository
![Page 20: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/20.jpg)
--++ Add a file --++ --++ --++ --++ --++ --++ --++ --++ --++ --++ --++
Start coding/adding files
$ echo "Please read me" > README
$ echo "Learn git now!" > TODO
![Page 21: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/21.jpg)
--++ Add a file --++ --++ --++ --++ --++ --++ --++ --++ --++ --++ --++
Files are added into a buffer zone (index)
Content of this zone is included in the next commit
Now git will track the changes made to these files
![Page 22: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/22.jpg)
--++ Show changes --++ --++ --++ --++ --++ --++ --++ --++ --++
Show the status of index and working dir
$ git status # files are untracked
$ git add README # add content to index
$ git add TODO # add content to index
$ git status # changes ready to be commited
![Page 23: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/23.jpg)
--++ Show changes --++ --++ --++ --++ --++ --++ --++ --++ --++
Index now contains working dir content
![Page 24: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/24.jpg)
--++ Commit changes --++ --++ --++ --++ --++ --++ --++ --++ --++
A commit is a snapshot taken from the index at some point in time
![Page 25: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/25.jpg)
--++ Commit changes --++ --++ --++ --++ --++ --++ --++ --++ --++
Saves the contents of index to the repo
Commit is inserted in the history of the branch
Each commit has an ID (SHA1 hash)
![Page 26: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/26.jpg)
--++ Commit changes --++ --++ --++ --++ --++ --++ --++ --++ --++
$ git commit -m “First commit” # First commit
Update files
$ echo "Try to cook" > TODO
$ echo "Once upon a time" > README
![Page 27: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/27.jpg)
--++ Commit changes --++ --++ --++ --++ --++ --++ --++ --++ --++
$ git status # Changes not staged for commit TODO + README
$ git add TODO # Changes to be commited TODO
$ git status # Changes not staged for commit
$ git commit -m "Update TODO file"
$ git status # Changes not staged for commit (README)
![Page 28: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/28.jpg)
--++ Print log commit --++ --++ --++ --++ --++ --++ --++ --++ --++
$ git log
Print log of commits of current branch
Gives hashes, authors, descriptions, dates
$ git log --pretty
![Page 29: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/29.jpg)
--++ Remove a file --++ --++ --++ --++ --++ --++ --++ --++ --++ --++
$ git rm <file>
Delete a file from the current directory
The file is no longer tracked by git
Next commit will contain instructions to remove the file
$ git rm TODO
![Page 30: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/30.jpg)
--++ Jump to a commit --++ --++ --++ --++ --++ --++ --++ --++ --
$ git checkout <commit ID>
Allows you to change the status of working directory
Files can be reverted to a previous version
![Page 31: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/31.jpg)
--++ Jump to a commit --++ --++ --++ --++ --++ --++ --++ --++ --
$ cat README
$ git checkout bb788e7e5d2059...
$ cat README
![Page 32: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/32.jpg)
--++ Add/commit workflow --++ --++ --++ --++ --++ --++ --++ --
![Page 33: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/33.jpg)
![Page 34: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/34.jpg)
--++ Intermediate Usage --++ --++ --++ --++ --++ --++ --++ --++ --
• Create branch (git branch branch_name)
• Put aside temporary changes (git stash)
• Merge branches (git merge)
• Push commits (git push)
• Pull commit (git pull)
![Page 35: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/35.jpg)
--++ Create a branch --++ --++ --++ --++ --++ --++ --++ --++ --++ --
$ git branch # List branches
$ git branch new_functionnality
Create branch that derives from current branch
Useful when developing a new feature
$ git checkout new_functionnality
$ git branch -D new_functionnality # Delete branch
![Page 36: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/36.jpg)
--++ Put aside changes --++ --++ --++ --++ --++ --++ --++ --++ --
Save temporary changes from index and working dir
$ git branch # branch new_functionnality
$ git status # Uncommited changes
$ git checkout master # Error
$ git stash # Saves working dir and index
![Page 37: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/37.jpg)
--++ Put aside changes --++ --++ --++ --++ --++ --++ --++ --++
$ git checkout master # Switch to master
$ git stash list
$ git stash show
$ git stash (apply || drop)
![Page 38: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/38.jpg)
--++ Merge branches --++ --++ --++ --++ --++ --++ --++ --++ --++ --
Merge a branch with the current branch
$ git checkout -b new_functionnality
$ echo "Take her phone" > TODO
$ echo "How to seduce women" > README
$ echo "Stop thinking too much" > new_file
![Page 39: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/39.jpg)
--++ Merge branches --++ --++ --++ --++ --++ --++ --++ --++ --++ --
$ git add new_file
$ git commit -m "Testing new functionnality"
$ git checkout master
$ cat new_file
$ git merge new_functionnality
![Page 40: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/40.jpg)
--++ Pull commits --++ --++ --++ --++ --++ --++ --++ --++ --++ --++ --
$ git pull <remote_depot> <remote_branch>
Download commit history of a remote branch (git fetch)
Performs merge with current branch (git merge)
Can generate conflicts
![Page 41: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/41.jpg)
--++ Push commits --++ --++ --++ --++ --++ --++ --++ --++ --++ --++
Sends commits to the history of a remote branch of a remote repository (help.github.com)
$ git remote add <name> <url>
$ git remote add origin [email protected]:username/hello_world.git
$ git push <remote_depot> <remote_branch>
$ git push origin master
![Page 42: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/42.jpg)
![Page 43: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/43.jpg)
Formation rapide en vidéo
--++ Thank you! --++ --++ --++ --++ --++ --++ --++ --++ --++ --++ --++
Any Question?
@BoubacarDiallo @Tutorys
![Page 44: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/44.jpg)
--++ Collaborative Working Process --++ --++ --++ --++ --++
Small commits with meaningful commit message
Test new functionnalities in separate branches
Merge branch into master
All tests should always pass on branch master
Push to staging when OK
Push to production
![Page 45: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/45.jpg)
--++ Resources --++ --++ --++ --++ --++ --++ --++ --++ --++ --++ --++
http://www.erlang-factory.com/upload/presentations/244/ErlangFactroySFBay2010-TomPreston-Werner.pdf
http://book.git-scm.com/
http://sixrevisions.com/resources/git-tutorials-beginners/
http://zrusin.blogspot.com/2007/09/git-cheat-sheet.html
http://www.slideshare.net/yannsionneau/introduction-git-8450451
![Page 46: Git a starter kit](https://reader031.vdocument.in/reader031/viewer/2022013121/554a5758b4c90531228b4ed9/html5/thumbnails/46.jpg)
--++ Videos --++ --++ --++ --++ --++ --++ --++ --++ --++ --++ --++ --++
Tom Preston-Werner - Mastering Git Basics http://vimeo.com/17118008
"Getting Git" by Scott Chacon http://vimeo.com/14629850
Linus Torvalds on Git http://www.youtube.com/watch?v=4XpnKHJAok8
Randal Schwartz on Git http://www.youtube.com/watch?v=8dhZ9BXQgc4
Git Tutorial Talk http://excess.org/article/2008/07/ogre-git-tutorial/