Presentation is loading. Please wait.

Presentation is loading. Please wait.

I Don’t Git It: A beginner’s guide to git Presented by Mathew Robinson

Similar presentations


Presentation on theme: "I Don’t Git It: A beginner’s guide to git Presented by Mathew Robinson"— Presentation transcript:

1 I Don’t Git It: A beginner’s guide to git Presented by Mathew Robinson
@chasinglogic

2 Who Am I Mathew Robinson DevOps Engineer for The Kroger Co. Linux/FOSS Enthusiast for 13 years Documentation Connoisseur Developer

3 So you want to contribute to OSS
So how many people in here have wanted to contribute to FOSS but have never gotten around to learning how?

4 But where do I start?

5 Git is the most ubiquitous tool in Open Source

6 What is Git? It's a Distributed Version Control System

7 A repository is a collection of commits, like a truck full of boxes

8 Create a repository with ‘git init’, like buying a new truck without any boxes
* using git will not improve your photo editing skills

9 Get someone else’s repository using ‘git clone’, like buying a copy of their truck with the same boxes Mine Yours

10 Commits are the boxes in the truck

11 Changes or “edits” are stored in the commits

12 Additionally the commits have messages that describe the changes inside
Update .gitignore

13 When working on your own repo, to make a commit first you’ll need to make some changes

14 Then you’ll need to use ‘git add’ to put those changes in the “staging area”
$ git add MANIFEST.in

15 From there ‘git commit’ will take all changes in the staging area and put them into a commit
$ git commit -m “update MANIFEST.in”

16 You now have added a commit to your repository!
update MANIFEST.in

17 But now you have a commit that the remote repository does not
Yours Mine update MANIFEST.in

18 And it’s likely the remote repository has commits that you do not
Yours Mine update MANIFEST.in Added new test

19 First you must ‘git pull’ to accept a delivery from the remote of the commits you don’t have
$ git pull origin master Yours Mine Added new test This is merging the commits, that’s why it’s called a pull request and not a merge request update MANIFEST.in Added new test

20 Now you can ‘git push’ to send a delivery of your commits to the remote repository
$ git push origin master Yours Mine Added new test update MANIFEST.in update MANIFEST.in Added new test

21 Now what if the remote had a commit which contains changes on the same file we changed?
Mine Yours

22 This causes a merge conflict because git does not know who’s version is right
Mine Yours

23 To solve this problem, we can use branching
Mine Yours

24 A branch takes a “snapshot” of the repo’s current HEAD (latest) commit
$ git checkout -b update-manifest Your freshly cloned repo Branch: update-manifest If this looks like cloning it should! While branching is a similar operation there is a reason that we do the branching Someone else’s change Someone else’s change

25 Now you can apply your change on your branch
Branch: master Branch: update-manifest update MANIFEST.in Someone else’s change Someone else’s change

26 Now when the remote is updated
Remote Branch: origin/master Branch: master Clean up MANIFEST.in Someone else’s change Someone else’s change

27 We can pull those changes into our copy of the master branch
$ git checkout master Remote Branch: origin/master Branch: master Clean up MANIFEST.in Someone else’s change Someone else’s change

28 We can pull those changes into our copy of the master branch
$ git pull origin master Remote Branch: origin/master Branch: master Clean up MANIFEST.in Clean up MANIFEST.in Someone else’s change Someone else’s change

29 Now we can merge or rebase as necessary
$ git checkout update-manifest $ git merge master # or $ git rebase -i master Branch: master Branch: update-manifest update MANIFEST.in Clean up MANIFEST.in Clean up MANIFEST.in Someone else’s change Someone else’s change

30 Now when we merge back to master it will fast-forward avoiding all merge conflicts
$ git checkout master $ git merge update-manifest Branch: master Branch: update-manifest update MANIFEST.in update MANIFEST.in Clean up MANIFEST.in Clean up MANIFEST.in Someone else’s change Someone else’s change

31 The same is true when we push our master branch back up to the remote
$ git push origin master Remote Branch: origin/master Branch: master update MANIFEST.in update MANIFEST.in Clean up MANIFEST.in Clean up MANIFEST.in Someone else’s change Someone else’s change

32 What we’ve covered git init git clone git add git commit git checkout git branch git merge && git rebase git push && git pull

33 $ git status Questions? You can find me on


Download ppt "I Don’t Git It: A beginner’s guide to git Presented by Mathew Robinson"

Similar presentations


Ads by Google