Git and github introduction
Qiang Zhang
May 27,2014
ABOUT GIT
what is git?
• git is CVS tool.
• The major difference between git and other CVS:
if files have not changed, Git doesn’t s...
Features
• Nearly Every Operation Is Local
• Git has three main states that your files can
reside in: committed, modified,...
An “hello world” example of git
• Install and intialize an empty git repo
>> sudo apt-get install -y git-core
>> mkdir myr...
Edit file and add it into git
>> git add file.txt
>> git status
>> git commit -m "Added first file"
>> git log
Main states of git
• Git has three main states that your files can
reside in:
– modified
– staged
– committed
state: modified
• Modified means that you have changed the file
but have not committed it to your database yet
• For examp...
state: staged
• Staged means mark a modified file which will go
into your next commit.
– If it’s modified and added to the...
state committed
• Committed means that the data is safely stored
in your local database.
• So git can trace all those chan...
Whole flow: Edit another file
and add to git
Edit your file locally
git status
git diff file.txt
git add file.txt
git...
CONTRIBUTE TO A PROJECT WITH
GITHUB
What is push ?
• When you have your project at a point that you
want to share, you have to push it upstream.
• Command: gi...
What is pull ?
• git-pull - Fetch from and integrate with another
repository or a local branch
• In its default mode: git ...
Create repo in github
• create repo in github website and push your
commit
– git remote add origin https://github.com/user...
Build the environment
1. Folk the repository on github website
2. Clone your folk:
git clone https://github.com/username/S...
first successful bugfix and
merge
1. Create the branch and switch to this branch
git branch Issue2020
git checkout Issue20...
Web resource
• https://try.github.io
step by step guide
• https://www.atlassian.com/git/
Very good tutorial and workflow o...
Upcoming SlideShare
Loading in...5
×

Git and github introduction

129

Published on

Git and github introduction

Published in: Software, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
129
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Git and github introduction

  1. 1. Git and github introduction Qiang Zhang May 27,2014
  2. 2. ABOUT GIT
  3. 3. what is git? • git is CVS tool. • The major difference between git and other CVS: if files have not changed, Git doesn’t store the file again—just a link to the previous identical file
  4. 4. Features • Nearly Every Operation Is Local • Git has three main states that your files can reside in: committed, modified, and staged. • Folk and pull model
  5. 5. An “hello world” example of git • Install and intialize an empty git repo >> sudo apt-get install -y git-core >> mkdir myrepo >> cd myrepo >> git config --global user.name "John Smith" >> git config --global user.email "example@stanford.edu" >> git init # Initialized empty Git repository in /home/ubuntu/myrepo/.git/ >> git status
  6. 6. Edit file and add it into git >> git add file.txt >> git status >> git commit -m "Added first file" >> git log
  7. 7. Main states of git • Git has three main states that your files can reside in: – modified – staged – committed
  8. 8. state: modified • Modified means that you have changed the file but have not committed it to your database yet • For example: you use vim open file.txt and add “hello, world” string. So file.txt is in modified state. • related commands: git checkout -- <filename> (undo the modification)
  9. 9. state: staged • Staged means mark a modified file which will go into your next commit. – If it’s modified and added to the staging area(git add file.txt), it is staged. – Otherwise, it is modified. • Related commands: git add, git diff --staged, git reset, git rm
  10. 10. state committed • Committed means that the data is safely stored in your local database. • So git can trace all those changes. • For example >> git commit -m "Added first file“ Related commands:
  11. 11. Whole flow: Edit another file and add to git Edit your file locally git status git diff file.txt git add file.txt git commit -m "Added a new line to the file." Command help output the committed logs git log git log -p git log -p --color
  12. 12. CONTRIBUTE TO A PROJECT WITH GITHUB
  13. 13. What is push ? • When you have your project at a point that you want to share, you have to push it upstream. • Command: git push [remote-name] [branch- name] • For example: git push -u origin master push local change to origin repo. The -u tells Git to remember the parameters, so that next time we can simply run git push
  14. 14. What is pull ? • git-pull - Fetch from and integrate with another repository or a local branch • In its default mode: git pull = git fetch + git merge FETCH_HEAD For example • git pull origin master Fetch the specified remote’s copy of the current branch and immediately merge it into the local copy.
  15. 15. Create repo in github • create repo in github website and push your commit – git remote add origin https://github.com/username/Hello- World.git # Creates a remote named "origin" pointing at your GitHub repository – git push origin master # Sends your commits in the "master" branch to GitHub origin
  16. 16. Build the environment 1. Folk the repository on github website 2. Clone your folk: git clone https://github.com/username/Spoon- Knife.git 3. Configure the remote: cd Spoon-Knife git remote add upstream <original repository> git fetch upstream git merge upstream/master
  17. 17. first successful bugfix and merge 1. Create the branch and switch to this branch git branch Issue2020 git checkout Issue2020 2. Make change at your branch: git status git add <file name> git commit -m “comments” 3. Switch to master repo and merge code 1. git checkout master 2. git merge Issue2020 3. git branch -d Issue2020 #delete Issue 2020 repo 4. Push your change back to github: git push origin master
  18. 18. Web resource • https://try.github.io step by step guide • https://www.atlassian.com/git/ Very good tutorial and workflow of git • Git cheatsheet
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×