際際滷

際際滷Share a Scribd company logo
@ssaunier
git & GitHub
for Beginners
Knowledge worker
We create and edit documents (text, images, etc.)
Everyday work鍖ow
1. Create a 鍖le
2. Save it
3. Edit it
4. Save it again
5. etc.
File life
Manual version control
Can we automate this?
For each document version, we need to know
1. When the 鍖le was modi鍖ed
2. What changed
3. Why it was modi鍖ed
Theres more, teams
Hence one more question
For each document version, we need to know
1. When the 鍖le was modi鍖ed
2. What changed
3. Why it was modi鍖ed
4. Who did the change
In a nutshell
We want a tool which
1. tracks document version
2. keeps an history of document changes
3. foster team work
Git & GitHub for Beginners
Set up
Download & install git at http://git-scm.com/
Your identity
$ git config --global user.name "Sebastien Saunier
$ git config --global user.email "seb@lewagon.org"
Basic commands
Starting
$ mkdir new_project
$ cd new_project
$ git init
Status
$ git status
git can tell you if your folder has some modi鍖ed 鍖les (dirty)
Commit
2-steps process
# Select which file to add to the commit.
$ git add <file_1_which_has_been_modified>
$ git add <file_2_which_has_been_modified>
# Take a snapshot of what is in the staging area.
$ git commit --message "A meaningful message about this change"
Diff
If git status tells you something changed,
you can inspect exactly what changed:
$ git diff
$ git diff <a_specific_file_or_folder>
Log
Show commit history with
$ git log
Branching
One feature = One branch
Branch
$ git branch my-feature
Working in the Branch
$ git checkout my-feature
$ git commit (x2)
Merge
$ git checkout master
$ git diff master..my-feature
$ git merge --no-ff my-feature
Clean up
$ git branch -d my-feature
Start Over
Remote
Git & GitHub for Beginners
Git & GitHub for Beginners
We need a remote!
Go to GitHub, create a repo: https://github.com/new
$ git remote add origin https://github.com/<user>/<project>.git
Push
Share the code with your team, and the world
# Generic command
$ git push <remote> <branch>
# What we'll use
$ git push origin master
Pull
# Generic command
$ git pull <remote> <branch>
# What we'll use
$ git pull origin master
Github Desktop app
desktop.github.com
Git & GitHub for Beginners
Pro鍖le page
Repository page
Commits & Branches
Pull requests
Issues
Forks
Open source contribution
Github pages
Hosting your website for free!
Repo example: lewagon/ui-components
Thank you!

More Related Content

Git & GitHub for Beginners