YOU ARE DOWNLOADING DOCUMENT

Please tick the box to continue:

Transcript
Page 1: Version Control Systems (VCS)utminers.utep.edu › ... › CPS5401_VersionControl.pdf · Version Control Systems Source control at a glance The preceding command to get a repository.

Version Control Systems (VCS)

Xianyi [email protected]

Department of Mathematical SciencesThe University of Texas at El Paso. September 13, 2016.

Page 2: Version Control Systems (VCS)utminers.utep.edu › ... › CPS5401_VersionControl.pdf · Version Control Systems Source control at a glance The preceding command to get a repository.

Version Control Systems

Let’s get the textbook!

• Online textbook: Victor Eijkhout, “Introduction to High-Performance Scientific Computing”.

http://pages.tacc.utexas.edu/~eijkhout/istc/

istc.html

• Get both the pdf version and source files.

https://bitbucket.org/VictorEijkhout/

hpc-book-and-course

• Fetch all the resources!

hg clone https://bitbucket.org/Victor

Eijkhout/hpc-book-and-course mycopy

Page 3: Version Control Systems (VCS)utminers.utep.edu › ... › CPS5401_VersionControl.pdf · Version Control Systems Source control at a glance The preceding command to get a repository.

Version Control Systems

Source control at a glance

• The preceding command to get a repository.

hg clone source target

VCS tool. Action. Repository. Local copy.

• Some common VCS tools:cvs: Concurrent version system.svn: Subversion.git: “The stupid content tracker”.hg: Mercurial.

• What do they do?Keep track the development history of a project.Maintain different versions of the project.Facilitate collaborations on the same project.Is NOT worry free!Mostly reliable on tracking text files.

Page 4: Version Control Systems (VCS)utminers.utep.edu › ... › CPS5401_VersionControl.pdf · Version Control Systems Source control at a glance The preceding command to get a repository.

Version Control Systems

Source control at a glance

• The preceding command to get a repository.

hg clone source target

VCS tool. Action. Repository. Local copy.

• Some common VCS actions:clone: Get the source from a repository.add/rm/mv/cp: File management of the source under control.checkout: Switch to a certain revision of a certain branch.commit: Save the changes and create a check point (reversion).diff: Compare different reversions.merge: Combine different branches.

Page 5: Version Control Systems (VCS)utminers.utep.edu › ... › CPS5401_VersionControl.pdf · Version Control Systems Source control at a glance The preceding command to get a repository.

A Simple Git Project

Get started: Record keeping

Let’s start a project on fluid-solid interaction.

• What do we do?Create a directory fsi.git and cd it.

mkdir fsi.git; cd fsi.git

Initiate a git repository

git init

This will create .git/

Create and add some files to the repository using: git add.Commit all the changes

git commit -m "Some development message"

This will create the first check point (revision) of the project.Continue to do so and create several revisions when appropriate.

Page 6: Version Control Systems (VCS)utminers.utep.edu › ... › CPS5401_VersionControl.pdf · Version Control Systems Source control at a glance The preceding command to get a repository.

A Simple Git Project

Get started: Record keeping

Let’s start a project on fluid-solid interaction.

• What can we do?Make a copy of the project:

git clone fsi.git loc.copy

Look at the development history:

git log

Switch back to a previous revision:

git checkout <rev.no>

Discussion: How about git reset or git revert?Compare two different revisions:

git diff <rev.1> <rev.2> [something]

Page 7: Version Control Systems (VCS)utminers.utep.edu › ... › CPS5401_VersionControl.pdf · Version Control Systems Source control at a glance The preceding command to get a repository.

A Simple Git Project

Create a new branch

Two people join and work on the fluid and solid, respectively.

• Create a new branch called “fluid”.Make a clone of the repository.

git clone fsi.git fluid.git

Create the new branch.

git branch fluid git checkout fluid

Page 8: Version Control Systems (VCS)utminers.utep.edu › ... › CPS5401_VersionControl.pdf · Version Control Systems Source control at a glance The preceding command to get a repository.

A Simple Git Project

Create a new branch

Two people join and work on the fluid and solid, respectively.

• Keep both the origin and current repositories updated.Push the new branch/any changes to the origin.

git push origin fluid:fluid

Gather the new information from the origin.git fetch origin

Pull the updates from the origin.git pull origin fluid:fluid

Page 9: Version Control Systems (VCS)utminers.utep.edu › ... › CPS5401_VersionControl.pdf · Version Control Systems Source control at a glance The preceding command to get a repository.

A Simple Git Project

Merge branches and resolve conflicts

Let’s say we make some progress on master, and want to getanything new from fluid.

When we are on the branch master:• Attempt to merge the branch fluid.

git merge fluid

• An automatic algorithm is called to merge the two branches.

• Upon success, both the sources and the logs are merged.

• Upon success, a new commit is created.

Page 10: Version Control Systems (VCS)utminers.utep.edu › ... › CPS5401_VersionControl.pdf · Version Control Systems Source control at a glance The preceding command to get a repository.

A Simple Git Project

Merge branches and resolve conflicts

Let’s say we make some progress on master, and want to getanything new from fluid.

When automatic merge fails, we need to resolve the conflicts:• Option 1: choose which version to keep.

• Option 2: manually modify the conflicted files.

• Once finished, mark the conflict as resolved and commit.

• Won’t be able to commit if there are unresolved conflicts.

Page 11: Version Control Systems (VCS)utminers.utep.edu › ... › CPS5401_VersionControl.pdf · Version Control Systems Source control at a glance The preceding command to get a repository.

Other VCS Systems and Resources

Repository models and concurrency models

Repository model.

• Client-server model:Developers access a master repository via a client (local working copy).Any changes must be committed to the master repository.The server maintains a full development history.Examples: cvs, svn.

• Distributed model:Repositories act as peers.Any peer can talk to any other peer/peers.Each repository maintain its version history.Examples: git, hg.

Page 12: Version Control Systems (VCS)utminers.utep.edu › ... › CPS5401_VersionControl.pdf · Version Control Systems Source control at a glance The preceding command to get a repository.

Other VCS Systems and Resources

Repository models and concurrency models

Concurrency model.

• “Lock” model:Only allow one user to modify one file at the a time.A user must “lock” a file before making changes to it.Usually only possible in a client-server model.Example: svn.

• “Merge” model:Many developers are allowed to edit the same file simutaneously.Users are informed of possible conflicts upon merging.Distributed system almost always implies a “merge” model.Examples: cvs, svn, git, hg.

• Do not bet everything on the lock-unlock model, or the au-tomatic merge.Developers should talk to each other whenever necessary!

Page 13: Version Control Systems (VCS)utminers.utep.edu › ... › CPS5401_VersionControl.pdf · Version Control Systems Source control at a glance The preceding command to get a repository.

Other VCS Systems and Resources

Further reading

A very good tutorial on git:https://www.atlassian.com/git/tutorials/

learn-git-with-bitbucket-cloud

A graphical guide to mercurial:https://www.mercurial-scm.org/wiki/

UnderstandingMercurial

Eclipse: A GUI for various version control systems.http://www.eclipse.org

Bitbucket: A web-based hosting service that we will use forsubmitting lab assignment for this course.

https://bitbucket.org