36
Who, what and why How P&O - git Marco Patrignani KU Leuven Marco Patrignani P&O - git 1/15

P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

  • Upload
    others

  • View
    10

  • Download
    0

Embed Size (px)

Citation preview

Page 1: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

P&O - git

Marco Patrignani

KU Leuven

Marco Patrignani P&O - git 1/15

Page 2: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

Outline

1 Who, what and why

2 How

Marco Patrignani P&O - git 2/15

Page 3: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

These slides

http://people.cs.kuleuven.be/∼marco.patrignani/Research.htmlTeaching (scroll down) → 2014-2015 → slides on git

Marco Patrignani P&O - git 3/15

Page 4: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

Who uses git?

Linux http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git

Google https://github.com/googleFacebook https://github.com/facebookMicrosoft http://aspnetwebstack.codeplex.com/Twitter https://github.com/twitterlinkedin https://github.com/linkedinAndroidhttps://android-review.googlesource.com/#/q/status:open,n,z. . .

Marco Patrignani P&O - git 4/15

Page 5: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

Who uses git?

Linux http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.gitGoogle https://github.com/googleFacebook https://github.com/facebookMicrosoft http://aspnetwebstack.codeplex.com/Twitter https://github.com/twitterlinkedin https://github.com/linkedinAndroidhttps://android-review.googlesource.com/#/q/status:open,n,z. . .

Marco Patrignani P&O - git 4/15

Page 6: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

What is git?

git [wikipedia]Git is a distributed revision control and source code management(SCM) system.

Distributed revision control system [wikipedia][a program that] keeps track of software revisions and allows manydevelopers to work on a given project without requiring that theymaintain a connection to a common network.

Marco Patrignani P&O - git 5/15

Page 7: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

What is git?

git [wikipedia]Git is a distributed revision control and source code management(SCM) system.

Distributed revision control system [wikipedia][a program that] keeps track of software revisions and allows manydevelopers to work on a given project without requiring that theymaintain a connection to a common network.

Marco Patrignani P&O - git 5/15

Page 8: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

git in a nutshell

create your repo (where the code is located)

a repo is a folder (with hidden files for git to manage)manage the repo by adding files/directories/binaries etcwhen a file is added, its history is recorded by git (this isversioning)commit changescommits describe the changes to the repo and who did themcreate new features in branches that do not affect the mainprojectbranches represent independent lines of development that canbe merged in the main linemaintain a remote repo to share access to it with multipleprogrammers

Marco Patrignani P&O - git 6/15

Page 9: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

git in a nutshell

create your repo (where the code is located)a repo is a folder (with hidden files for git to manage)

manage the repo by adding files/directories/binaries etcwhen a file is added, its history is recorded by git (this isversioning)commit changescommits describe the changes to the repo and who did themcreate new features in branches that do not affect the mainprojectbranches represent independent lines of development that canbe merged in the main linemaintain a remote repo to share access to it with multipleprogrammers

Marco Patrignani P&O - git 6/15

Page 10: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

git in a nutshell

create your repo (where the code is located)a repo is a folder (with hidden files for git to manage)manage the repo by adding files/directories/binaries etc

when a file is added, its history is recorded by git (this isversioning)commit changescommits describe the changes to the repo and who did themcreate new features in branches that do not affect the mainprojectbranches represent independent lines of development that canbe merged in the main linemaintain a remote repo to share access to it with multipleprogrammers

Marco Patrignani P&O - git 6/15

Page 11: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

git in a nutshell

create your repo (where the code is located)a repo is a folder (with hidden files for git to manage)manage the repo by adding files/directories/binaries etcwhen a file is added, its history is recorded by git (this isversioning)

commit changescommits describe the changes to the repo and who did themcreate new features in branches that do not affect the mainprojectbranches represent independent lines of development that canbe merged in the main linemaintain a remote repo to share access to it with multipleprogrammers

Marco Patrignani P&O - git 6/15

Page 12: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

git in a nutshell

create your repo (where the code is located)a repo is a folder (with hidden files for git to manage)manage the repo by adding files/directories/binaries etcwhen a file is added, its history is recorded by git (this isversioning)commit changes

commits describe the changes to the repo and who did themcreate new features in branches that do not affect the mainprojectbranches represent independent lines of development that canbe merged in the main linemaintain a remote repo to share access to it with multipleprogrammers

Marco Patrignani P&O - git 6/15

Page 13: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

git in a nutshell

create your repo (where the code is located)a repo is a folder (with hidden files for git to manage)manage the repo by adding files/directories/binaries etcwhen a file is added, its history is recorded by git (this isversioning)commit changescommits describe the changes to the repo and who did them

create new features in branches that do not affect the mainprojectbranches represent independent lines of development that canbe merged in the main linemaintain a remote repo to share access to it with multipleprogrammers

Marco Patrignani P&O - git 6/15

Page 14: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

git in a nutshell

create your repo (where the code is located)a repo is a folder (with hidden files for git to manage)manage the repo by adding files/directories/binaries etcwhen a file is added, its history is recorded by git (this isversioning)commit changescommits describe the changes to the repo and who did themcreate new features in branches that do not affect the mainproject

branches represent independent lines of development that canbe merged in the main linemaintain a remote repo to share access to it with multipleprogrammers

Marco Patrignani P&O - git 6/15

Page 15: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

git in a nutshell

create your repo (where the code is located)a repo is a folder (with hidden files for git to manage)manage the repo by adding files/directories/binaries etcwhen a file is added, its history is recorded by git (this isversioning)commit changescommits describe the changes to the repo and who did themcreate new features in branches that do not affect the mainprojectbranches represent independent lines of development that canbe merged in the main line

maintain a remote repo to share access to it with multipleprogrammers

Marco Patrignani P&O - git 6/15

Page 16: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

git in a nutshell

create your repo (where the code is located)a repo is a folder (with hidden files for git to manage)manage the repo by adding files/directories/binaries etcwhen a file is added, its history is recorded by git (this isversioning)commit changescommits describe the changes to the repo and who did themcreate new features in branches that do not affect the mainprojectbranches represent independent lines of development that canbe merged in the main linemaintain a remote repo to share access to it with multipleprogrammers

Marco Patrignani P&O - git 6/15

Page 17: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

Why using git?

easy to share code among developers

cannot lose code by accidentkeeps the history of codeallows one to maintain different versions of code, to compareand merge themthat’s what good software developers do

Marco Patrignani P&O - git 7/15

Page 18: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

Why using git?

easy to share code among developerscannot lose code by accident

keeps the history of codeallows one to maintain different versions of code, to compareand merge themthat’s what good software developers do

Marco Patrignani P&O - git 7/15

Page 19: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

Why using git?

easy to share code among developerscannot lose code by accidentkeeps the history of code

allows one to maintain different versions of code, to compareand merge themthat’s what good software developers do

Marco Patrignani P&O - git 7/15

Page 20: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

Why using git?

easy to share code among developerscannot lose code by accidentkeeps the history of codeallows one to maintain different versions of code, to compareand merge them

that’s what good software developers do

Marco Patrignani P&O - git 7/15

Page 21: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

Why using git?

easy to share code among developerscannot lose code by accidentkeeps the history of codeallows one to maintain different versions of code, to compareand merge themthat’s what good software developers do

Marco Patrignani P&O - git 7/15

Page 22: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

How to use git

https://www.atlassian.com/git/tutorial (expected in the firstreport)https://www.atlassian.com/git/workflows (centralised and thefeature branch workflows are recommended)

Marco Patrignani P&O - git 8/15

Page 23: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

Useful software

http://sourcetreeapp.com/ for Mac and Winhttp://www.syntevo.com/smartgit/download for Mac, Winand Linuxcommand linelist of all laptop apps http://git-scm.com/downloads/guismobile appshttps://play.google.com/store/apps/details?id=com.saibotd.bitbeaker

Marco Patrignani P&O - git 9/15

Page 24: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

git commands

git init – turns the current directory into a repo

git clone <repo> – Clone the repository located at <repo>in the current directory (this is what you’ll do)

Marco Patrignani P&O - git 10/15

Page 25: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

git commands

git init – turns the current directory into a repogit clone <repo> – Clone the repository located at <repo>in the current directory (this is what you’ll do)

Marco Patrignani P&O - git 10/15

Page 26: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

git commands

git add <f> – Adds file f (or directory f) to the repo (notadded until commit is done)

git commit -m "<message>" – Commits changes to the repogit revert <commit> – Undo all of the changes introducedin <commit>

Marco Patrignani P&O - git 11/15

Page 27: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

git commands

git add <f> – Adds file f (or directory f) to the repo (notadded until commit is done)git commit -m "<message>" – Commits changes to the repo

git revert <commit> – Undo all of the changes introducedin <commit>

Marco Patrignani P&O - git 11/15

Page 28: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

git commands

git add <f> – Adds file f (or directory f) to the repo (notadded until commit is done)git commit -m "<message>" – Commits changes to the repogit revert <commit> – Undo all of the changes introducedin <commit>

Marco Patrignani P&O - git 11/15

Page 29: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

git commands

git branch <branch> – Create a new branch called <branch>

git checkout <existing-branch> – This makes<existing-branch> the current branch (watch out fordetached HEADs)git merge <branch> – Merge the specified branch into thecurrent branch

Marco Patrignani P&O - git 12/15

Page 30: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

git commands

git branch <branch> – Create a new branch called <branch>

git checkout <existing-branch> – This makes<existing-branch> the current branch (watch out fordetached HEADs)

git merge <branch> – Merge the specified branch into thecurrent branch

Marco Patrignani P&O - git 12/15

Page 31: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

git commands

git branch <branch> – Create a new branch called <branch>

git checkout <existing-branch> – This makes<existing-branch> the current branch (watch out fordetached HEADs)git merge <branch> – Merge the specified branch into thecurrent branch

Marco Patrignani P&O - git 12/15

Page 32: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

git ignore

create a file called .gitignore

add regular expressions for files NOT to include in the repofor example *.o *.a

Marco Patrignani P&O - git 13/15

Page 33: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

The workflow

centralised Central repo. Each contributor clones it, edits herlocal copy and pushes his local changes remotely.Before pushing, she pulls for other people’s pushesand merges eventual conflicts.

feature-branch Like above, but a new feature is started in adifferent branch (to avoid conflicts). Oncecompleted, it is merged in the master. Othercontributors see the branch but can ignore it.

Marco Patrignani P&O - git 14/15

Page 34: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

The workflow

centralised Central repo. Each contributor clones it, edits herlocal copy and pushes his local changes remotely.Before pushing, she pulls for other people’s pushesand merges eventual conflicts.

feature-branch Like above, but a new feature is started in adifferent branch (to avoid conflicts). Oncecompleted, it is merged in the master. Othercontributors see the branch but can ignore it.

Marco Patrignani P&O - git 14/15

Page 35: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

The workflow

centralised Central repo. Each contributor clones it, edits herlocal copy and pushes his local changes remotely.Before pushing, she pulls for other people’s pushesand merges eventual conflicts.

feature-branch Like above, but a new feature is started in adifferent branch (to avoid conflicts). Oncecompleted, it is merged in the master. Othercontributors see the branch but can ignore it.

Marco Patrignani P&O - git 14/15

Page 36: P&O - gittheory.stanford.edu/~mp/mp/Teaching_files/git.pdf · Who, what and why How P&O-git MarcoPatrignani KU Leuven Marco Patrignani P&O - git 1/15

Who, what and whyHow

P&O specifics

register on https://bitbucket.org/ with yourstudent.kuleuven accountcheck your plan inManage account → plan details → change plan

upgrade to academic licensehttps://www.atlassian.com/software/views/bitbucket-academic-license.jspcreate a Team called KULPnO14-15_thenameofyourteam.E.g. KULPnO14-15_zilveradd your group supervisors to the team with Administratorprivileges

Marco Patrignani P&O - git 15/15