Windows. Everywhere else

Similar documents
2 Initialize a git repository on your machine, add a README file, commit and push

git commit --amend git rebase <base> git reflog git checkout -b Create and check out a new branch named <branch>. Drop the -b

Git Tutorial. André Sailer. ILD Technical Meeting April 24, 2017 CERN-EP-LCD. ILD Technical Meeting, Apr 24, 2017 A. Sailer: Git Tutorial 1/36

Submitting your Work using GIT

So#ware(Project. Lecture'4. Wouter'Swierstra. So#ware(project( (Lecture(4 1

Distributed Version Control Git

Version Control System - Git. zswu

Chapter 5. Version Control: Git

GETTING STARTED WITH. Michael Lessard Senior Solutions Architect June 2017

Git Guide. Meher Krishna Patel. Created on : Octorber, 2017 Last updated : October, More documents are freely available at PythonDSP

Git AN INTRODUCTION. Introduction to Git as a version control system: concepts, main features and practical aspects.

Git, the magical version control

Getting the files for the first time...2. Making Changes, Commiting them and Pull Requests:...5. Update your repository from the upstream master...

Agenda. - Final Project Info. - All things Git. - Make sure to come to lab for Python next week

Version Control. Software Carpentry Github s Hello World Git For Ages 4 And Up You need source code control now

git Version: 2.0b Merge combines trees, and checks out the result Pull does a fetch, then a merge If you only can remember one command:

The Old World. Have you ever had to collaborate on a project by

Visualizing Git Workflows. A visual guide to 539 workflows

Introduction to Git and GitHub for Writers Workbook February 23, 2019 Peter Gruenbaum

From Commits to Collaboration: A Git Tutorial for Social Scientists

Git. Charles J. Geyer School of Statistics University of Minnesota. Stat 8054 Lecture Notes

About SJTUG. SJTU *nix User Group SJTU Joyful Techie User Group

GIT tutorial. David Parsons, Soraya Arias, Thomas Calmant November, Preamble 2

Assumptions. GIT Commands. OS Commands

Git for Newbies. ComMouse Dongyue Studio

A Brief Introduction to Git. Sylverie Herbert (based on slides by Hautahi Kingi)

Lab 08. Command Line and Git

Effective Programming Practices for Economists. 7. Version Control, Part II: Git with a Shared Repository

Git AN INTRODUCTION. Introduction to Git as a version control system: concepts, main features and practical aspects.

Using GitHub to Share with SparkFun a

Lab 01 How to Survive & Introduction to Git. Web Programming DataLab, CS, NTHU

CS 520: VCS and Git. Intermediate Topics Ben Kushigian

Software Project (Lecture 4): Git & Github

Git better. Collaborative project management using Git and GitHub. Matteo Sostero March 13, Sant Anna School of Advanced Studies

DEAD-SIMPLE VERSION CONTROL FOR YOUR TEAM GIT WITH MATTHEW REIDSMA GRAND VALLEY STATE UNIVERSITY

Version Control. Version Control

Working in Teams CS 520 Theory and Practice of Software Engineering Fall 2018

Introduction to Git For Groups

Introduction to Git and Github

How to version control like a pro: a roadmap to your reproducible & collaborative research

Effective Software Development and Version Control

Version Control Systems

Creating a Patch. Created by Carl Heymann on 2010 Sep 14 1

git the SCM system Jan-Simon Möller training.linuxfoundation.org

Revision Control and GIT

Working with GIT. Florido Paganelli Lund University MNXB Florido Paganelli MNXB Working with git 1/47

Source Code Management wih git

Git Workflows. Sylvain Bouveret, Grégory Mounié, Matthieu Moy

EECS 470 Lab 4. Version Control System. Friday, 31 st January, 2014

GIT FOR SYSTEM ADMINS JUSTIN ELLIOTT PENN STATE UNIVERSITY

USING GIT FOR AUTOMATION AND COLLABORATION JUSTIN ELLIOTT - MATT HANSEN PENN STATE UNIVERSITY

Version Control: Gitting Started

Review Version Control Concepts

Git AN INTRODUCTION. Introduction to Git as a version control system: concepts, main features and practical aspects.

#25. Use Source Control in a Single- Developer Environment

Version control system (VCS)

Computer Science Design I Version Control with Git

1/20/13 Git tutorial. Git tutorial. Mike Nolta. file:///users/nolta/github/reveal.js/git.html?print-paper#/ 1/31

GIT. CS 490MT/5555, Spring 2017, Yongjie Zheng

Git(Lab) Tutorial and Hands-On

Beyond git add/commit/push

CS 390 Software Engineering Lecture 5 More Git

Git and GitHub. Dan Wysocki. February 12, Dan Wysocki Git and GitHub February 12, / 48

Git. Presenter: Haotao (Eric) Lai Contact:

213/513/613 Linux/Git Bootcamp. Cyrus, Eugene, Minji, Niko

Introduction to Git. Let us list below some of the best known and most widely used version control systems:

An introduction to Git and GitHub

API RI. Application Programming Interface Reference Implementation. Policies and Procedures Discussion

b. Developing multiple versions of a software project in parallel

Revision control. INF5750/ Lecture 2 (Part I)

Versioning with git. Moritz August Git/Bash/Python-Course for MPE. Moritz August Versioning with Git

Version Control System GIT

Git tutorial. Katie Osterried C2SM. October 22, 2015

Lab Exercise Git: A distributed version control system

What is git? Distributed Version Control System (VCS); Created by Linus Torvalds, to help with Linux development;

Object Oriented Programming. Week 1 Part 2 Git and egit

Introduction to Supercomputing

Version Control. Version Control

Use git rm to remove files from workspace

Github/Git Primer. Tyler Hague

Index. Alias syntax, 31 Author and commit attributes, 334

Improving Your Life With Git

LAB MANUAL GIT BY PRATIK JAIN. To start with git bash, we need to authenticate ourselves so that for every commit, git can use this information.

git and the virtue of version control ECE /2/2015

Intermediate Programming, Spring Misha Kazhdan

GIT Princípy tvorby softvéru, FMFI UK Jana Kostičová,

Version Control with GIT

Tips on how to set up a GitHub account:

Software Development. Using GIT. Pr. Olivier Gruber. Laboratoire d'informatique de Grenoble Université de Grenoble-Alpes

Git Tutorial. Version: 0.2. Anders Nilsson April 1, 2014

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

Version control. what is version control? setting up Git simple command-line usage Git basics

Table of Contents. Concepts


Software Development I


Revision Control. How can 4. Slides #4 CMPT 276 Dr. B. Fraser. Local Topology Simplified. Git Basics. Revision Control:

! #Running this command from the top directory of your project will add all your changes."! $ git add."

What is version control? (discuss) Who has used version control? Favorite VCS? Uses of version control (read)

GIT DISTRIBUTED IS THE NEW CENTRALISED

Transcription:

Git version control Enable native scrolling Git is a tool to manage sourcecode Never lose your coding progress again An empty folder 1/30 Windows Go to your programs overview and start Git Bash Everywhere else Open a terminal window 2/30 working dir. cd into the directory where you save your python projects Type mkdir test to create a new empty folder called test Type cd test to go to the new folder 3/30 working dir. Open your text editor and create the files and with some dummy content like hello world or test Save the files to the folder you created on the previous slide Type ls in the terminal to verify that you saved the files correctly 4/30

working dir. The folder in which you saved the files is called the working directory we now want to manage this directory using git 5/30 working dir. staging area history To make the current directory a git repository type git init on the terminal git init creates a hidden.git folder in the working directory to store all its data Type ls -a to see the hidden.git directory Type ls.git to see the content of the.git directory working dir. staging area history 6/30 We want git to keep track of our and files Git does not perform any automatic synchronizations in the background like e.g. Dropbox does Instead we have to manually inform git about changes we made to the files in the working directory 7/30

$ git status On branch master Initial commit Untracked files: (use "git add <file>..." to include in what will be committed) nothing added to commit but untracked files present (use "git add" to track) Use the git status command to find the files in the working directory that git does not yet track working dir. staging area history 6d9627000451 8/30 On the previous slide git told us to use git add to start tracking and Type git add on the terminal git add creates copies of the files and saves them under the.git directory It also calculates hash values that uniquely identify the contents of the files Commits 9/30 $ git status On branch master Initial commit Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: new file: If we now rerun git status it will tell us, that and are "to be committed" Commits 10/30 A commit in git is a snapshot of the whole project at a given time As long as you do not actively break your git repository you can always go back to every previous commit in your git history E.g. when you accidentially delete one of your source-files you will only lose the work you did since the last commit Or when your project stops working you can always go back to a previous version that is known to work and find the breaking change 11/30

Commits In order to create a new commit you: git add every file that you want to be part of the commit use git status to check if you included all your changes Type git commit -m "Your description here" You should replace "Your description here" by a description of the changes you did since the last commit working dir. staging area history 6d9627000451 8645990523a6 12/30 In the example we are now about to commit the changes to and Type git commit -m "" as this is our first commit in this repository You can now use git log to see the history of this repository Commit #2 13/30 For the next commit we want to output "Hello World!" when it is executed Replace the text you put into text.py with the following program: 1 print('hello World!') Create a commit that includes the new Make sure to give it a good description of the changes working dir. staging area history Better 3bf43600e385 14/30 The second commit stores: A reference to the previous commit A description "Better " References to the old and the new Use git log to look at the history of the project 15/30

Syncing Although not losing any local work is already a great feature git can do even more One of the other mayor features is being able to synchronize repositories with a server This allows you to simultaneously collaborate on software over the internet Syncing 16/30 Sign into/create an account on a codesharing site that supports git like Gitlab, Bitbucket or Github Syncing 17/30 In order to use a git-based codesharing site you have to generate a ssh public key once and configure the site to associate it with your account Click here for a tutorial on how to generate a public key 18/30

Syncing After configuring your public key you can create a new project Syncing 19/30 copy the address of the new project 20/30

Syncing working dir. staging area history server Better 3bf43600e385 and add it to your git repository as a remote using the command: git remote add origin [address of the project] 21/30 Syncing working dir. staging area history server Better 3bf43600e385 Better 3bf43600e385 Once again git does not perform any automatic synchronizations. In order to publish your changes to the server you have to use the git push command To setup this remote as a default type git push --set-upstream origin master to push your changes to the server 22/30

Collaborating In order to collaborate on a project you have to add another user as a developer to the project Add a partner to your project server Better 3bf43600e385 23/30 To get a copy of an already existing repository you can use the git clone command Ask your partner for the address she/he used in the git remote add [address] command Type cd.. to go one directory up Type git clone [address] partner to get a copy of your partners code into a new partner folder Outlook 24/30 Git has a lot more feature than we covered here We have not covered: What to do if you and your partner made changes to the code at the same time How to retrieve old commits What branches are Merging, rebasing, stashing But as long as you stick to the commands that were demonstrated in this turorial you will not lose progress because of accidentially overwritten/deleted files 25/30

CheatSheet - Commands git init - Initialize a repository in the current directory git remote add - Tell git that you want to use a server git clone - Clone a remote repository git status - Run this command whenever you need advise git add - Tell git about the newest version of a file git commit - Create a snapshot of the current state and give it a name git pull - Get the latest commits from a server git push - Send the latest commits to a server Git kaputt 26/30 $ git push To remote! [rejected] master -> master (fetch first) error: failed to push some refs to 'remote' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. Problem: git push gets rejected when there are changes on the server you do not have locally Workaround: git pull the changes first Git kaputt 27/30 $ git pull remote: Counting objects: 3, done. remote: Total 3 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (3/3), done. From remote bcdbca8..0a78d9b master -> origin/master Updating bcdbca8..0a78d9b error: Your local changes to the following files would be overwritten by merge: Please commit your changes or stash them before you merge. Aborting Problem: git pull complains about uncommited files Workaround: git add and git commit your local changes and git pull again Git kaputt 28/30 $ git pull Auto-merging CONFLICT (content): Merge conflict in Automatic merge failed; fix conflicts and then commit the result. Problem: git pull complains because you and someone else edited the same file Workaround: Go through every file git complains about, search for any occurence of <<<<<<< and decide which version you want to keep. git add and git commit the new version. 29/30

Git kaputt Problem: Everything is broken, nothing works, my computer is on fire Workaround: Clone the repository from the server, forget about your old repository and get a fire extinguisher 30/30