Introduction to The Git Version Control System

Slides:



Advertisements
Similar presentations
An Introduction By Sonali and Rasika.  Required for the project  Show the versions of your code in the course of development  Show versions of your.
Advertisements

Version Control with git. Version Control Version control is a system that records changes to a file or set of files over time so that you can recall.
1 CSE 390 “Lecture 11” Version control with Git slides created by Ruth Anderson, images from
Introduction to Git and Github Joshua imtraum.com.
Git for Version Control These slides are heavily based on slides created by Ruth Anderson for CSE 390a. Thanks, Ruth! images taken from
Fundamentals of Git By Zachary Ling 29 th, Aug,
علیرضا فراهانی استاد درس: جعفری نژاد مهر Version Control ▪Version control is a system that records changes to a file or set of files over time so.
Git – versioning and managing your software L. Grewe.
Version control Using Git Version control, using Git1.
Version Control Systems academy.zariba.com 1. Lecture Content 1.What is Software Configuration Management? 2.Version Control Systems (VCS) 3.Basic Git.
…using Git/Tortoise Git
Git workflow and basic commands By: Anuj Sharma. Why git? Git is a distributed revision control system with an emphasis on speed, data integrity, and.
Team 708 – Hardwired Fusion Created by Nam Tran 2014.
1 GIT NOUN \’GIT\ A DISTRIBUTED REVISION CONTROL AND SOURCE CODE MANAGEMENT (SCM) SYSTEM WITH AN EMPHASIS ON SPEED. INITIALLY DESIGNED AND DEVELOPED BY.
Version Control System Lisa Palathingal 03/04/2015.
GIT.
Intro to Git presented by Brian K. Vagnini Hosted by.
Introduction to Git Yonglei Tao GVSU. Version Control Systems  Also known as Source Code Management systems  Increase your productivity by allowing.
© 2015 by Herb Holyst Introduction to git Cytomics Workshop December, 2015.
Introduction to Git - Chirag Dani. Objectives Basics of Git Understanding different “Mindset of Git” Demo - Git with Visual Studio.
INTRODUCTION TO GIT. Install Egit for eclipse Open eclipse->Help->Install New Software Search for one of the following -
Git How to 1. Why Git To resolve problems in lab exams (accidental deletions) Use existing Libraries with ease (Statistics and Computer) Prepare undergraduates.
1 Ivan Marsic Rutgers University LECTURE 2: Software Configuration Management.
Installing git In Linux: sudo apt-get install git In Windows: download it from run the setuphttp://git-scm.com/download/win.
BIT 285: ( Web) Application Programming Lecture 07 : Tuesday, January 27, 2015 Git.
Getting Started with Git Presented by Jim Taylor Rooty Hollow, Owner Verizon Wireless, Senior Programmer/Analyst Git User for 6 years.
Jun-Ru Chang Introduction GIT Jun-Ru Chang
Backing up a machine with git
KIT – University of the State of Baden-Wuerttemberg and National Research Center of the Helmholtz Association STEINBUCH CENTRE FOR COMPUTING - SCC
Basics of GIT for developers and system administrators
CS5220 Advanced Topics in Web Programming Version Control with Git
M.Sc. Juan Carlos Olivares Rojas
Information Systems and Network Engineering Laboratory II
Primož Gabrijelčič Git for Programmers Primož Gabrijelčič
Git and GitHub primer.
11 Version control (part 2)
CReSIS Git Tutorial.
Git-Github Safa Prepared for the course COP4331 – Fall 2016.
LECTURE 2: Software Configuration Management
Version Control.
Git Practice walkthrough.
Version Control overview
Version control, using Git
File Version Control System
CS5220 Advanced Topics in Web Programming Version Control with Git
Macaualy2 Workshop Berkeley 2017
Storing, Sending, and Tracking Files Recitation 2
An introduction to version control systems with Git
Version Control with Git accelerated tutorial for busy academics
SU Development Forum Introduction to Git - Save your projects!
Distributed Version Control with git
Akshay Narayan git up to speed with RCS Akshay Narayan
An introduction to version control systems with Git
Version Control with git
LECTURE 3: Software Configuration Management
The Big Picture
SIG: Open Week 1: GitHub Tim Choh.
Git-Github Tools Prepared for COP4331. Git-Github Tools Prepared for COP4331.
Version Control System - Git
Version control with Git
Introduction to Git and GitHub
Version Control with Git
Version Control with Git and GitHub
GitHub 101 Using Github and Git for Source Control
Git Introduction.
Git GitHub.
Introduction To GitHub
Introduction To GitHub
Advanced Git for Beginners
Presentation transcript:

Introduction to The Git Version Control System Last modified April 2019 Introduction to The Git Version Control System Ziv Yaniv, Ph.D. GitHub CheatSheet: https://github.github.com/training-kit/downloads/github-git-cheat-sheet.pdf Git reference: https://git-scm.com/docs “Pro Git”, Chacon and Straub: https://git-scm.com/book/en/v2

Version Control System “A system that records changes to a file or set of files over time so that you can recall specific versions later.”* centralized (e.g. svn): distributed (e.g. mercurial): server client client/ server client/ server With centralized vcs each of the developers is only a client that has a copy of the current version’s files and performs commits to the central server. With distributed vcs each of the developrs has a full copy of the repository and its history and performs commits to their local server. They can then share commits with other servers. In theory, all servers in the distributed vcs can have the same level of authoritativeness (in practice this isn’t how it works). *Pro Git local

Version Control System “A system that records changes to a file or set of files over time so that you can recall specific versions later.”* centralized (e.g. svn): distributed with forking workflow (e.g. git): server client hosting service: client/ server client/ server client/ server client/ server local: client/ server client/ server client/ server client/ server *Pro Git local

Git “A distributed version-control system for tracking changes in source code during software development” [wikipedia]. Free Open Source Software (FOSS) under GNU General Public License version 2. Linus Torvalds – Git Creator Junio Hamano – Git Maintainer And 1200+ contributors “Faces of Open Source” project, Peter Adams http://www.facesofopensource.com/

Installation and Interaction Install Git (https://git-scm.com/downloads) Use git: Command line tool (old school) Dedicated GUI front end Part of your IDE (Rstudio, Visual Studio…) https://git-scm.com/downloads/guis/

General Setup (One Time) Hierarchical configuration (each layer overrides the preceding one): All users on the system: /usr/local/git/etc/gitconfig All of your repositories: ~/.gitconfig A specific repository: my_repository_directory/.git/config git config --list --show-origin git config --global user.name “Ziv Yaniv” git config --global user.email “zivyaniv@nih.gov” git config --global core.editor emacs Show my setup. List of configurable settings: https://git-scm.com/docs/git-config

General Setup (One Time) If you work on the command line, configure your prompt to display the branch (in your .bashrc on unix): source /usr/share/git-core/contrib/completion/git-prompt.sh PS1='[\[\[\e[1;32m\]$(__git_ps1 "(%s)")\[\e[m\] \[\e[0;31m\]\w\[\e[m\]]' To configure prompt on your specific system “google”: display git branch in prompt your_operating_system

Words of Caution Do not commit large binary files into a git repository, use Git Large File Storage (Git-LFS). NEVER commit files that contain critical/private information (passwords, AWS access keys). You will make mistakes – fix them locally before you share with the world (push to shared repository). Any change to a binary file will result in creation of a new copy of the whole file, significant growth in repository size. Once a file is committed and pushed to a remote repo expunging it from the repo(s) is hard. ‘git rm’ only removes it from the current version it is still in the history. Once you push to shared repo other people will have the file when they update their copy of the repo.

Starting - One Time Setup Create a new repository: git init Create a local copy of an existing repository: git clone https://github.com/zivy/SimpleITK-Notebooks.git git clone git@github.com:zivy/SimpleITK-Notebooks.git https or ssh: firewall issues may dictate which one you end up using. https requires username-password (config-don’t-type, either store or cache): git config credential.helper store ssh setup: instructions from bitbucket: https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html instructions from github: https://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#generating-a-new-ssh-key

Starting – Looking Around git status : show working tree status, used all the time. git log : show all commits (and merges). git remote –v : show all remote repositories, used once in a while. git branch –a –vv : show all branches, used once in a while. When using a GUI, most often, this information is readily visible.

Starting – Git is all about branches Branch types: Local, non tracking: local repo branch (e.g. updateTutorials) Local, tracking: local repo branch tracking another branch (e.g. master) Remote branch: remote repo branch Remote tracking branch: local copy of remote repo branch (remotes/origin/updateReadme)

Adding File(s) Into The Current Branch A two step process?, repeat till done: Stage files for commit: git add f1.py f2.py… Check the status before commiting: git status Commit: git commit A single branch repo: master – default branch name. HEAD – pointer to last commit on currently checked out branch. c0 c1 c2 master HEAD

Working with Branches Create a new branch and check it out: git checkout –b my_branch my_branch (h) c0 c1 c2 master

Working with Branches Create a new branch and check it out: git checkout –b my_branch Add commits. my_branch (h) c3 c4 c0 c1 c2 master

Working with Branches Checkout the master branch: my_branch c3 c4 c0 git checkout master my_branch c3 c4 c0 c1 c2 master (h)

Working with Branches Checkout the master branch: Add commits. git checkout master Add commits. my_branch c3 c4 c0 c1 c2 c5 c6 master (h)

Working with Branches Checkout the master branch: Add commits. git checkout master Add commits. Merge my_branch into master branch (v1): git merge my_branch my_branch c3 c4 c0 c1 c2 c5 c6 c7 master (h)

Working with Branches Checkout the master branch: Add commits. git checkout master Add commits. Merge my_branch into master branch (v2): git checkout my_branch git rebase master git checkout master git merge my_branch my_branch c0 c1 c2 c5 c6 c3’ c4’ master (h)

To Err is Human Undo staging: git reset file_name Correct an error in the last commit (rewriting history): edit file git add file_name git commit --amend Undo commit(s): git reset HEAD^ [--hard to get rid of the changes] git reset HEAD~n [n commits back]

No Repository is an Island Adding a remote repository: git remote add remote_name remote_url Updating your checked out local tracking branch: git pull equivalent to git fetch remote_tracking_branch git merge remote_tracking_branch Updating a remote repository: git push remote_repo_name branch_name -u: add tracking reference if you want the current local non tracking branch to track the remote one you are creating. -f: force the push, rewriting history on the remote repo.

Forking Workflow One time setup: Fork repository of interest on git hosting service (GitHub/Bitbucket/…), let’s call it ‘repo’. Locally clone: git clone git@github.com:your_username/repo.git Add the original repository as a remote, usually named ‘upstream’: git remote add upstream git@github.com:repo_username/repo.git Check that we have two remote repositories (origin, upstream): git remote -v

Forking Workflow If not synched with upstream repository, synch before beginning to work: git fetch upstream git checkout master git merge upstream/master Create branch on which you will work: git checkout –b my-branch-name Write code+tests and commit locally: git add my_file git commit my_file Push branch to your repository on hosting service: git push origin my-branch-name On the hosting service site, open a pull request from my-branch-name to the upstream repository (possibly triggering CI testing). Owner of the upstream repository will do a code review. Repeat steps 3,4,6 until the branch is merged into the upstream repository. Delete the branch on your remote and local repositories: git push origin --delete my-branch-name git branch –d my-branch-name

https://github.com/SimpleITK Thank You Open Source Software: don’t just use it, contribute to it: https://github.com/SimpleITK