FEEG6002 - Applied Programming 3 - Version Control and Git II



Similar documents
Git Basics. Christopher Simpkins Chris Simpkins (Georgia Tech) CS 2340 Objects and Design CS / 22

MATLAB & Git Versioning: The Very Basics

Lab Exercise Part II: Git: A distributed version control system

MOOSE-Based Application Development on GitLab

Introduction to the Git Version Control System

Using Git for Project Management with µvision

Version Control with Git. Linux Users Group UT Arlington. Rohit Rawat

Introduc)on to Version Control with Git. Pradeep Sivakumar, PhD Sr. Computa5onal Specialist Research Compu5ng, NUIT

Version Control using Git and Github. Joseph Rivera

Version Control. Version Control

Version control with GIT

Version control. with git and GitHub. Karl Broman. Biostatistics & Medical Informatics, UW Madison

Introduction to Git. Markus Kötter Notes. Leinelab Workshop July 28, 2015

Version Control! Scenarios, Working with Git!

Annoyances with our current source control Can it get more comfortable? Git Appendix. Git vs Subversion. Andrey Kotlarski 13.XII.

Version Control with Svn, Git and git-svn. Kate Hedstrom ARSC, UAF

Git - Working with Remote Repositories

Version Control with Git. Kate Hedstrom ARSC, UAF

Source Control Systems

Version Control with. Ben Morgan

Introducing Xcode Source Control

Source Code Management for Continuous Integration and Deployment. Version 1.0 DO NOT DISTRIBUTE

Version Control with Subversion

Working Copy 1.4 users manual

Version Control Script

Two Best Practices for Scientific Computing

Version Control with Git. Dylan Nugent

Version Control with Git

Putting It All Together. Vagrant Drush Version Control

Data management on HPC platforms

A Git Development Environment

Version Control with Subversion and Xcode

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer GIT

Derived from Chris Cannam's original at, an.

CSE 374 Programming Concepts & Tools. Laura Campbell (Thanks to Hal Perkins) Winter 2014 Lecture 16 Version control and svn

Using GitHub for Rally Apps (Mac Version)

Version Control Systems

Version Control with Mercurial and SSH

How to Create a Free Private GitHub Repository Educational Account

CPSC 491. Today: Source code control. Source Code (Version) Control. Exercise: g., no git, subversion, cvs, etc.)

Version Control with Git

Version Control for Computational Economists: An Introduction

Introduction to Version Control with Git

Mercurial. Why version control (Single users)

Unity Version Control

Using Git for Centralized and Distributed Version Control Workflows - Day 3. 1 April, 2016 Presenter: Brian Vanderwende

Introduction to Version Control

The Hitchhiker s Guide to Github: SAS Programming Goes Social Jiangtang Hu d-wise Technologies, Inc., Morrisville, NC

An Introduction to Mercurial Version Control Software

Gitflow process. Adapt Learning: Gitflow process. Document control

Using Subversion in Computer Science

Work. MATLAB Source Control Using Git

Git. A Distributed Version Control System. Carlos García Campos carlosgc@gsyc.es

Git Basics. Christian Hanser. Institute for Applied Information Processing and Communications Graz University of Technology. 6.

A Brief Introduction to the Command Line and Git

Version control. HEAD is the name of the latest revision in the repository. It can be used in subversion rather than the latest revision number.

Dalhousie University CSCI 2132 Software Development Winter 2015 Lab 7, March 11

CS 2112 Lab: Version Control

Distributed Version Control with Mercurial and git

Dry Dock Documentation

Version Uncontrolled! : How to Manage Your Version Control

Introweb Remote Backup Client for Mac OS X User Manual. Version 3.20

ECE 4750 Computer Architecture, Fall 2015 Tutorial 2: Git Distributed Version Control System

Revision control systems (RCS) and

Subversion. Nadir SOUALEM. Linux Users subversion client svn or higher. Windows users subversion client Tortoise 1.6.

Continuous Integration and Delivery at NSIDC

Extending Remote Desktop for Large Installations. Distributed Package Installs

Introduction to Version Control with Git

Distributed Version Control

Quick Start Guide. Cerberus FTP is distributed in Canada through C&C Software. Visit us today at

1. Product Information

STABLE & SECURE BANK lab writeup. Page 1 of 21

Source Control Guide: Git

Upgrade your Software

Accessing the FTP Server - User Manual

Using SVN to Manage Source RTL

Git in control of your Change Management

How to set up SQL Source Control. The short guide for evaluators

An Introduction to Mercurial Version Control Software

How to FTP (How to upload files on a web-server)

What Does Tequila Have to Do with Managing Macs? Using Open Source Tools to Manage Mac OS in the Enterprise!

BlueJ Teamwork Tutorial

Jazz Source Control Best Practices

AVOIDING THE GIT OF DESPAIR

NLP Programming Tutorial 0 - Programming Basics

MySQL Quick Start Guide

Backup and Restore the HPOM for Windows 8.16 Management Server

Hadoop Data Warehouse Manual

Memopol Documentation

Online Backup Client User Manual Linux

Continuous Delivery on AWS. Version 1.0 DO NOT DISTRIBUTE

Software Configuration Management and Continuous Integration

NAS 225 Introduction to FTP Explorer

StriderCD Book. Release 1.4. Niall O Higgins

RecoveryVault Express Client User Manual

DevShop. Drupal Infrastructure in a Box. Jon Pugh CEO, Founder ThinkDrop Consulting Brooklyn NY

Transcription:

FEEG6002 - Applied Programming 3 - Version Control and Git II Sam Sinayoko 2015-10-16 1 / 26

Outline Learning outcomes Working with a single repository (review) Working with multiple versions of a repository Advanced features Online repositories Conclusions Appendix 2 / 26

Outline Learning outcomes Working with a single repository (review) Working with multiple versions of a repository Advanced features Online repositories Conclusions Appendix 3 / 26

Learning outcomes By the end of this lecture you should be able to: work with multiple copies of a Git repository git clone git pull git push create an account and a private repository for the C labs on Bitbucket to easily work on multiple computers keep your C programs for the labs / coursework under version control 4 / 26

Outline Learning outcomes Working with a single repository (review) Working with multiple versions of a repository Advanced features Online repositories Conclusions Appendix 5 / 26

Working with a single repository Command Description git init Initialize a version controlled repository git add Add file(s) to repository (or staging area) git commit -a -m "Sth" Commit all changes (creates a new commit) git log List the commit history git checkout 5096a Revert the repository to commit 5096a git checkout -f 5096a Discard all changes and revert to 5096a git checkout master Revert to latest commit (= master) git show 5096a Display some info about commit 5096a git diff 5096a 730a3 Display the diff between commits 5096a and 7 master Latest commit (in the default master branch) HEAD The current commit HEAD^ Head s parent HEAD~i Head s i th parent 6 / 26

Original repository contents Change directory to last week s repository and checkout master 1 # cd /path/to/my/repos/feeg6002-git-basics git checkout master # make sure we ve got the latest commi ls # list directory s contents Your branch is up-to-date with origin/master. wise.txt There is only one file, wise.txt, whose content is cat wise.txt - Your country is the best country in the world - Your city is the best city in the world - Your food is the best in the world 1 Alternatively see Appendix A for how to download a copy of the repository from Bitbucket. 7 / 26

Original repository log file git log commit 2b483859fceb1c19a9862593b61e1a99fcc0e39d Author: Sam Sinayoko <s.sinayoko@soton.ac.uk> Date: Thu Oct 15 16:29:36 2015 +0100 Nice guy commit bbed77870c10468aaa6a086feb6273628632e123 Author: Sam Sinayoko <s.sinayoko@soton.ac.uk> Date: Thu Oct 15 16:29:00 2015 +0100 France lover commit 7556a41f57860373ad7051eda1b6f0ac284b990c Author: Sam Sinayoko <s.sinayoko@soton.ac.uk> Date: Thu Oct 15 16:23:53 2015 +0100 8 / 26

Make some more changes and commit Let s add some details to wise.txt: - Your country is the best country in the world + welcoming people + great climate - Your city is the best city in the world + great parks + vibrant night life + beautiful architecture - Your food is the best in the world git commit -a -m "Add details on country and city." [master 2cb4f93] Add details on country and city. 1 file changed, 5 insertions(+) 9 / 26

Outline Learning outcomes Working with a single repository (review) Working with multiple versions of a repository Advanced features Online repositories Conclusions Appendix 10 / 26

Cloning a repository (git clone) Motivation Working on the same program on multiple computers: each computer must have a copy, or clone, of the repository. Working on the same program with several people: each person must have a clone of the repository. Making extensive changes that are kept independent of your original repository. Syntax Make a copy of the repository in the current folder "git clone /path/to/original-repo" creates a copy of the entire repository in the current folder, with the same name. "git clone /path/to/original-repo new-repo" renames the repository to "new-repo" 11 / 26

Cloning a repository (git clone) Go to parent directory of original repository cd.. ls # (go back to parent directory) # (directory contents before cloning) feeg6002-git-basics Clone the repository git clone feeg6002-git-basics feeg6002-angry # (creates new folder feeg6002-angry ) Directory after cloning ls # (feeg6002-angry has appeared) feeg6002-angry feeg6002-git-basics 12 / 26

(Optional) Change the username in the new repository Let s change the user name to "Mr Hyde". This is just to distinguish him later from the original user "Sam Sinayoko" in the revision history. You wouldn t normally have to do this, since another user would already have a different name. cd feeg6002-angry git config user.name "Mr Hyde" git config user.email "mrhyde@darkplace.com" 13 / 26

Make some (angry) changes to the new repository Edit "wise.txt" as follows: - Your country is NOT the best country in the world + unwelcoming people + terrible climate - Your city is NOT the best city in the world + dirty parks + boring night life + ugly architecture - Your food is NOT the best in the world Don t forget to commit: git commit -a -m "Mr Hyde is ANGRY tonight" 14 / 26

Pulling changes from another repository (git pull) In the oringal repository we can pull the changes from Mr Hyde: cd../feeg6002-git-basics # go back to original repo git pull../feeg6002-angry # pull the changes into the orig Updating 2cb4f93..71e46cd Fast-forward wise.txt 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) Similarly, if "Sam Sinayoko" commits any new changes to the original repository, "Mr Hyde" can use: git pull to incorporate the commits to his repository. There is a similar command to push commits to a remote repository called git push. 2 2 However this is only possible when the the remote repository is not checked in the same branch 15 / 26

Outline Learning outcomes Working with a single repository (review) Working with multiple versions of a repository Advanced features Online repositories Conclusions Appendix 16 / 26

Dealing with "simultaneous" revisions: merging If there are new commits in both the local repository and the remote one, git pull attempts to merge the two commits. This is only possible if there are not conflicts. If there is a conflict in a file, git puts the two possible versions within the file one after the other, and the conflict must be dealt with manually. See Bonus Video on Blackboard. You should use the command git status to find out whether you have dealt with all the changes. After dealing with all conflicts we can commit again. 17 / 26

Outline Learning outcomes Working with a single repository (review) Working with multiple versions of a repository Advanced features Online repositories Conclusions Appendix 18 / 26

Online repositories (Bitbucket & Github) Git repositories can be hosted for free on Bitbucket http://www.bitbucket.org Repositories can be public or private Private repositories are visible only by people you authorize. Public repositories can be cloned by anyone. Private repositories use the secure protocols SSH or HTTPS. SSH requires further configuration steps so stick to HTTPS for now. A popular alternative site is GitHub https://github.com, but it does not offer private repositories for free accounts. Just create a new repository on the website and follow the instructions to clone data to it. 19 / 26

TODO: Create a repository on Bitbucket for the labs Create an account on Bitbucket http://www.bitbucket.org Create a new repository for the labs called feeg6002-labs Use git clone to get a copy of your Bitbucket repository on your local computer. For example create a folder repos to store all your future repositories, change to that directory in the terminal and run # cd /path/to/repos # splitting line over two lines wit \ because it s long git clone \ https://sinayoko@bitbucket.org/sinayoko/feeg6002-labs Cloning into feeg6002-labs... warning: You appear to have cloned an empty repository. Checking connectivity... done. 20 / 26

TODO: Use your Bitbucket repository in the labs In the labs you can put the repos folder in your Documents folder Put your C programs in that folder and use Git to keep them under version control with: git add git commit -a -m etc. Note: there is no need to initialize the repository because Bitbucket does that automatically. Create a folder for each lab in your folder repos/feeg6002-labs and add your programs to it 21 / 26

TODO: Push your commits to your Bitbucket repository At the end of each session (at home or in the lab), use git push to upload all your commits to Bitbucket git push Password for https://sinayoko@bitbucket.org : Counting objects: 21, done.... To https://sinayoko@bitbucket.org/sinayoko/feeg6002-labs * [new branch] master -> master If you use a version of Git older than 2.0, the firs time you do this you ll get an error. Run this command to fix it before pushing again. git config --global push.default simple At the start of each lab using git pull to get an up to date copy of your repository 22 / 26

Outline Learning outcomes Working with a single repository (review) Working with multiple versions of a repository Advanced features Online repositories Conclusions Appendix 23 / 26

Conclusions Summary of the key commands git clone create local copy of a repository git pull pull changes from the original repository git push push changes to the original repository Use Bitbucket to create a private repository online for the labs Clone it locally with the https protocol, add your new programs for each lab, make commits and push your changes. 24 / 26

Outline Learning outcomes Working with a single repository (review) Working with multiple versions of a repository Advanced features Online repositories Conclusions Appendix 25 / 26

Appendix A: cloning the repository from lecture 2 I have created a public repository containing the repository from lecture 2. You can clone on your local machine by running this command # splitting command over two lines with \ git clone \ https://sinayoko@bitbucket.org/sinayoko/feeg6002-git-basics Cloning into feeg6002-git-basics... remote: Counting objects: 12, done. remote: Compressing objects: 100% (9/9), done. remote: Total 12 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (12/12), done. Checking connectivity... done. This will create a repository in your current folder called feeg6002-git-basics. 26 / 26