version control - york university fileversion control! scenarios, working with git!! scenario 1!!...

81
Version Control Scenarios, Working with Git

Upload: vuongphuc

Post on 21-Jun-2019

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Version Control!

Scenarios, Working with Git!

!

Page 2: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Scenario 1!

n  You finished the assignment at home !

VC–2

Page 3: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Scenario 1b!

n  You finished the assignment at home!n  You get to York to submit and realize you did not upload it!

VC–3

Page 4: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Scenario 1c!

n  You finished the assignment at home!n  You get to York to submit and realize you did not upload it!

n  Has this ever happened to you? !

VC–4

Page 5: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Scenario 2!

n  Your program works pretty well!

VC–5

Page 6: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Scenario 2b!

n  Your program works pretty well!

n  You make a lot of improvements!

VC–6

Page 7: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Scenario 2c!

n  Your program works pretty well!

n  You make a lot of improvements!n  But you haven’t got them to work yet!

VC–7

Page 8: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Scenario 2d!

n  Your program works pretty well!

n  You make a lot of improvements!n  But you haven’t got them to work yet!

n  You need to demo your program now!

VC–8

Page 9: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Scenario 3!

n  You are working on the 2.0 version of “your great app” but 2.0 does not quite compile yet … and a customer finds a critical bug in 1.0, which must be fixed ASAP!

VC–9

Page 10: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Scenario 3b!

n  You are working on the 2.0 version of “your great app” but 2.0 does not quite compile yet … and a customer finds a critical bug in 1.0, which must be fixed ASAP!

n  If you are smart, you have a copy of your 1.0 source. You make the change and release it but how do you merge your changes into your 2.0 program text?!

VC–10

Page 11: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Scenario 3c!

n  You are working on the 2.0 version of “your great app” but 2.0 does not quite compile yet … and a customer finds a critical bug in 1.0, which must be fixed ASAP!

n  If you are smart, you have a copy of your 1.0 source. You make the change and release it but how do you merge your changes into your 2.0 program text?!

n  You you are not so smart, you have no source program text saved. !

VC–11

Page 12: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Scenario 3d!

n  You are working on the 2.0 version of “your great app” but 2.0 does not quite compile yet … and a customer finds a critical bug in 1.0, which must be fixed ASAP!

n  If you are smart, you have a copy of your 1.0 source. You make the change and release it but how do you merge your changes into your 2.0 program text?!

n  You you are not so smart, you have no source program text saved. !n  You have no way to track down the bug and you lose face

until 2.0 is ready!

VC–12

Page 13: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Scenario 4!

n  You change one part of a program!

VC–13

Page 14: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Scenario 4b!

n  You change one part of a program!n  It works!

VC–14

Page 15: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Scenario 4c!

n  You change one part of a program!n  It works!

n  Your teammate changes another part!

VC–15

Page 16: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Scenario 4d!

n  You change one part of a program!n  It works!

n  Your teammate changes another part!n  It works!

VC–16

Page 17: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Scenario 4e!

n  You change one part of a program!n  It works!

n  Your teammate changes another part!n  It works!

n  You put it together!

VC–17

Page 18: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Scenario 4f!

n  You change one part of a program!n  It works!

n  Your teammate changes another part!n  It works!

n  You put it together!n  It DOES NOT WORK!

VC–18

Page 19: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Scenario 4g!

n  You change one part of a program!n  It works!

n  Your teammate changes another part!n  It works!

n  You put it together!n  It DOES NOT WORK!

n  What were all the changes?!

!

VC–19

Page 20: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Scenario 5!

n  You make a number of improvements to a class!

VC–20

Page 21: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Scenario 5b!

n  You make a number of improvements to a class!

n  Your teammate makes a number of different improvements to the same class!

n  How can you merge these changes?!

VC–21

Page 22: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

A poor solution!

n  There are a number of tools that help you spot changes – differences – between two files, such as diff!

VC–22

Page 23: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

A poor solution – 2!

n  There are a number of tools that help you spot changes – differences – between two files, such as diff!

n  Of course, they won’t help unless you kept a copy of the older version!

VC–23

Page 24: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

A poor solution – 3!

n  There are a number of tools that help you spot changes – differences – between two files, such as diff!

n  Of course, they won’t help unless you kept a copy of the older version!

n  Differencing tools are useful for finding a small number of differences in a few files!

VC–24

Page 25: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

A poor solution – 4!

n  There are a number of tools that help you spot changes – differences – between two files, such as diff!

n  Of course, they won’t help unless you kept a copy of the older version!

n  Differencing tools are useful for finding a small number of differences in a few files!

n  A better solution …!

VC–25

Page 26: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Version control systems!

n  Keep multiple, older and newer, versions of everything!

VC–26

Page 27: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Version control systems – 2!

n  Keep multiple, older and newer, versions of everything!n  Not just program source text!

VC–27

Page 28: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Version control systems – 3!

n  Keep multiple, older and newer, versions of everything!n  Not just program source text!

n  Request comments regarding every change!

VC–28

Page 29: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Version control systems – 4!

n  Keep multiple, older and newer, versions of everything!n  Not just program source text!

n  Request comments regarding every change!

n  Display differences between versions!

VC–29

Page 30: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Version control systems – 5!

n  Keep multiple, older and newer, versions of everything!n  Not just program source text!

n  Request comments regarding every change!

n  Display differences between versions!

n  Allow merging of changes on the same file!

VC–30

Page 31: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Centralized version control!

n  Traditional version control system!n  Server with database!n  Clients have a working version!

VC–31

Page 32: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Centralized version control – 2!

n  Traditional version control system!n  Server with database!n  Clients have a working version!

n  Examples!n  CVS!n  Subversion!

VC–32

Page 33: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Centralized version control – 3!

n  Traditional version control system!n  Server with database!n  Clients have a working version!

n  Examples!n  CVS!n  Subversion!

n  Challenges!n  Multi-developer conflicts!n  Client/server communication!

VC–33

Page 34: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Distributed version control – 2!

n  Authoritative server by convention only!

n  Every working checkout is a repository!

VC–34

Page 35: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Distributed version control – 3!

n  Authoritative server by convention only!

n  Every working checkout is a repository!

n  Get version control even when detached!

VC–35

Page 36: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Distributed version control – 5!

n  Authoritative server by convention only!

n  Every working checkout is a repository!

n  Get version control even when detached!

n  Backups are trivial!

n  Examples!n  Git!n  Bitkeeper!

VC–36

Page 37: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Terminology!

n  A repository contains several branches!

VC–37

Page 38: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Terminology – 2!

n  A repository contains several branches!

n  The main branch is call the master!

VC–38

Page 39: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Terminology – 3!

n  A repository contains several branches!

n  The main branch is call the master!

n  Branches break off from the master to try something new, e.g. a new feature, program text restructuring, etc.!

VC–39

Page 40: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Terminology – 4!

n  A repository contains several branches!

n  The main branch is call the master!

n  Branches break off from the master to try something new, e.g. a new feature, program text restructuring, etc.!

n  Branches can be merged with other branches or into the master!

VC–40

Page 41: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Terminology – 5!

n  A repository contains several branches!

n  The main branch is call the master!

n  Branches break off from the master to try something new, e.g. a new feature, program text restructuring, etc.!

n  Branches can be merged with other branches or into the master!

n  Tags are usually official releases that have to be supported!

VC–41

Page 42: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Working with git!

n  We do the following!n  Create a repository online!

VC–42

Page 43: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Working with git – 2!

n  We do the following!n  Create a repository online!n  Create a local repository, add a project to it, and push it to

the online repository!

VC–43

Page 44: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Working with git – 3!

n  We do the following!n  Create a repository online!n  Create a local repository, add a project to it, and push it to

the online repository!n  All team members get the online repository!

VC–44

Page 45: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Working with git – 4!

n  We do the following!n  Create a repository online!n  Create a local repository, add a project to it, and push it to

the online repository!n  All team members get the online repository!n  Changes pushed by one team member can now be pulled

by all!

VC–45

Page 46: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Creating the repository!

n  Once per tem!n  Go to github.com!n  Sign up for a new account!n  Create a new repository!n  Copy the URL to access your repository!

!

VC–46

Page 47: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Creating a local project repository!

n  Once per team (practice example)!n  Run Eclipse!n  Create a new project called ProjectWithGit that contains a

main method that prints “Fun with Git”!n  Go to Eclipse -> Preferences -> Team -> Git -> Configuration!n  Click Add Entry, add the pair [user.name, your_name]!n  Click Add Entry, add the pair [user.email, your_email]!

n  These should be the same as the ones used at github.com!

n  Click Apply, then OK!

VC–47

Page 48: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Creating a local project repository – 2!

n  Once per team (practice example) – cont’d!n  Right click on ProjectWithGit

and Select Team -> Share Project …!n  Click on Create …!n  Provide a name for your local repository, and click Finish!

n  Your local repository is now setup!

VC–48

Page 49: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Pushing the first local repository!

n  Once per team (practice example) – cont’d!n  Right click on ProjectWithGit

and select Team -> Commit!n  Provide name and email!n  Add a commit message!

n  It is important that you add a message every time you commit – makes it easier to find a version later!

n  Select all files, and click Commit!n  Close editors, reopen, make a change to the output of your

program and Commit again!

VC–49

Page 50: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Pushing the first local repository – 2!

n  Once per team (practice example) – cont’d!n  Right click on ProjectWithGit

and select Team -> Remote -> Push!n  Copy the URL from github.com in the URI field!n  Enter your github.com username and password,

click NEXT!n  Select master from from the Source ref pull down menu!n  Click on Add All Branches Spec!n  Click Finish, then OK!

n  You should be able to see ProjectWithGit in github.com!

VC–50

Page 51: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Deleting the local repository!

n  Once per team (practice example) – cont’d!n  Due to an Eclipse but, it is easy to delete the local

repository, and re-get it from github.com along with the other team members!

n  Right click on ProjectWithGit in Eclipse select Delete!

n  Select to delete project contents on disk, and click OK!

VC–51

Page 52: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Copying a repository!

n  All team members!n  Start Eclipse!n  Go to File -> Import -> Git -> Projects from Git!n  Click Next, select Clone URI,!n  Keep clicking Next until you can click Finish!

n  You now have a copy of the project in your local repository!

n  To push changes to the remote repository, you will need a github.com account that is added as a collaborator!

VC–52

Page 53: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Push to repository!

n  Each team member!n  Make some changes to any of the classes in the project!n  Right click on any element that has changes (could be the

whole project), and select Team -> Commit!n  Add a commit message!n  If you do not want to publish the changes yet, click Commit!n  If the changes are ready to be published, click Commit and

Push!

VC–53

Page 54: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Pull from repository!

n  To get changes published by other team members!n  Right click on the project, and select Team -> Pull!

VC–54

Page 55: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Homework!

n  Get git working for every team member!

n  For program text / documents / notes etc.!

n  Demonstrate that everybody can pull / push program text in the next lab.!

VC–55

Page 56: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Subversion (SVN)!

n  A server holds all original files of a project!

!

VC–56

Page 57: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Subversion – 2!

n  A server holds all original files of a project!

n  Gives out copies to participants!

!

!

VC–57

Page 58: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Subversion – 3!

n  A server holds all original files of a project!

n  Gives out copies to participants!

n  Participants modify their copies and submit their changes to the server!

!

!

VC–58

Page 59: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Subversion – 4!

n  A server holds all original files of a project!

n  Gives out copies to participants!

n  Participants modify their copies and submit their changes to the server!

n  The server automatically merges changes into the original files!

!

!

VC–59

Page 60: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Subversion conflicts!

n  Conflicts only occur when modifications are done!

!

VC–60

Page 61: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Subversion conflicts – 2!

n  Conflicts only occur when modifications are done!n  By more than one participant!

!

VC–61

Page 62: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Subversion conflicts – 3!

n  Conflicts only occur when modifications are done!n  By more than one participant!n  At the same location in their respective copies!

!

VC–62

Page 63: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Subversion conflicts – 4!

n  Conflicts only occur when modifications are done!n  By more than one participant!n  At the same location in their respective copies!n  Then participants have to manually resolve such conflicts!

VC–63

Page 64: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

SVN support!

n  Powerful edit and merge tools help make conflict management easy!

VC–64

Page 65: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

SVN support – 2!

n  Powerful edit and merge tools help make conflict management easy!

n  SVN keeps a log of any changes made to any file!

VC–65

Page 66: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

SVN support – 3!

n  Powerful edit and merge tools help make conflict management easy!

n  SVN keeps a log of any changes made to any file!

n  Participants can go back and receive older versions of a file or even an older version of an entire project state!

VC–66

Page 67: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

SVN action – Checkout!

n  Receive a copy of an entire project from the SVN server!n  Source files!n  Project & make files!n  Resource files!n  Etc.!

VC–67

Page 68: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

SVN action – Update!

n  Receive copies of individual files or folders from the server!

n  Merges the copies with your current local copy!

VC–68

Page 69: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

SVN action – Commit!

n  Sends an updated file (your local copy) to the SVN server!

n  The copy is incorporated into the original project database!

n  A new version number is assigned!

VC–69

Page 70: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

SVN action – Commit – 2!

n  Sends an updated file (your local copy) to the SVN server!

n  The copy is incorporated into the original project database!

n  A new version number is assigned!

n  Before doing a commit!n  You must do an update (and resolve any possible conflicts)

before you commit.!

VC–70

Page 71: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

SVN action – Add!

n  Notifies SVN of a new file or folder that needs to be added to the existing project!n  Only if the SVN is aware of a file, can you commit the file!

VC–71

Page 72: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

SVN action – Add!

n  Notifies SVN of a new file or folder that needs to be added to the existing project!n  Only if the SVN is aware of a file, can you commit the file!n  You must use add before you can commit a new file or

folder!

VC–72

Page 73: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

SVN action – Add!

n  Notifies SVN of a new file or folder that needs to be added to the existing project!n  Only if the SVN is aware of a file, can you commit the file!n  You must use add before you can commit a new file or

folder!

n  To delete a file you need to!n  Delete it in your local folder!n  Then commit the folder!!

VC–73

Page 74: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Further considerations!

n  Make sure to update regularly otherwise!n  You will have lots of conflicts!n  And lots of problems!

VC–74

Page 75: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Further considerations – 2!

n  Make sure to update regularly otherwise!n  You will have lots of conflicts!n  And lots of problems!

n  SVN will not help you!n  If you do not commit regularly!

VC–75

Page 76: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Further considerations – 3!

n  Make sure to update regularly otherwise!n  You will have lots of conflicts!n  And lots of problems!

n  SVN will not help you!n  If you do not commit regularly!

n  If you add lots of new stuff!n  Make sure to commit everything!

VC–76

Page 77: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Git advantages!

n  Resilience!n  No one repository has more data than any other!

VC–77

Page 78: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Git advantages – 2!

n  Resilience!n  No one repository has more data than any other!

n  Speed!n  Very fast operations compared to other VCSs!

VC–78

Page 79: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Git advantages – 3!

n  Resilience!n  No one repository has more data than any other!

n  Speed!n  Very fast operations compared to other VCSs!

n  Space!n  Compression can be done across the repository, not just

per file!n  Minimizes local size as well as push / pull transfers!

VC–79

Page 80: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Git advantages – 4!

n  Resilience!n  No one repository has more data than any other!

n  Speed!n  Very fast operations compared to other VCSs!

n  Space!n  Compression can be done across the repository, not just per file!n  Minimizes local size as well as push / pull transfers!

n  Simplicity!n  Object model is simple!

VC–80

Page 81: Version control - York University fileVersion Control! Scenarios, Working with Git!! Scenario 1!! You finished the assignment at home !

Git advantages – 5!

n  Resilience!n  No one repository has more data than any other!

n  Speed!n  Very fast operations compared to other VCSs!

n  Space!n  Compression can be done across the repository, not just per file!n  Minimizes local size as well as push / pull transfers!

n  Simplicity!n  Object model is simple!

n  Large user base with robust tools!

VC–81