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

Post on 21-Jun-2019

219 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Version Control!

Scenarios, Working with Git!

!

Scenario 1!

n  You finished the assignment at home !

VC–2

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

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

Scenario 2!

n  Your program works pretty well!

VC–5

Scenario 2b!

n  Your program works pretty well!

n  You make a lot of improvements!

VC–6

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

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

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

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

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

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

Scenario 4!

n  You change one part of a program!

VC–13

Scenario 4b!

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

VC–14

Scenario 4c!

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

n  Your teammate changes another part!

VC–15

Scenario 4d!

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

n  Your teammate changes another part!n  It works!

VC–16

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

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

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

Scenario 5!

n  You make a number of improvements to a class!

VC–20

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

A poor solution!

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

VC–22

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

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

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

Version control systems!

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

VC–26

Version control systems – 2!

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

VC–27

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

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

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

Centralized version control!

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

VC–31

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

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

Distributed version control – 2!

n  Authoritative server by convention only!

n  Every working checkout is a repository!

VC–34

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

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

Terminology!

n  A repository contains several branches!

VC–37

Terminology – 2!

n  A repository contains several branches!

n  The main branch is call the master!

VC–38

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

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

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

Working with git!

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

VC–42

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

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

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

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

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

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

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

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

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

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

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

Pull from repository!

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

VC–54

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

Subversion (SVN)!

n  A server holds all original files of a project!

!

VC–56

Subversion – 2!

n  A server holds all original files of a project!

n  Gives out copies to participants!

!

!

VC–57

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

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

Subversion conflicts!

n  Conflicts only occur when modifications are done!

!

VC–60

Subversion conflicts – 2!

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

!

VC–61

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

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

SVN support!

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

VC–64

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

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

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

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

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

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

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

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

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

Further considerations!

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

VC–74

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

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

Git advantages!

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

VC–77

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

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

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

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

top related