Git, the magical version control

Similar documents
Git. Presenter: Haotao (Eric) Lai Contact:

Lecture 6 Remotes. Sign in on the attendance sheet!

Git tutorial. Katie Osterried C2SM. October 22, 2015

Use git rm to remove files from workspace

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

Assumptions. GIT Commands. OS Commands

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

Windows. Everywhere else

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

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:

Git. CSCI 5828: Foundations of Software Engineering Lecture 02a 08/27/2015

CPSC 491. Lecture 19 & 20: Source Code Version Control. VCS = Version Control Software SCM = Source Code Management

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

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

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

Tools for software development:

Version Control System - Git. zswu

Git for Subversion users

Git. A Distributed Version Control System. Carlos García Campos

Outline The three W s Overview of gits structure Using git Final stuff. Git. A fast distributed revision control system

Version Control: Gitting Started

Lab Objective. Lab Assignment. Downloads and Installation

Git. A fast distributed revision control system. Nils Moschüring PhD Student (LMU)

A L A TEX-oriented intro to Git

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

1. Which of these Git client commands creates a copy of the repository and a working directory in the client s workspace. (Choose one.

Revision Control and GIT

Revision control. INF5750/ Lecture 2 (Part I)

Github/Git Primer. Tyler Hague

Software Engineering

Software Project (Lecture 4): Git & Github

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

Using Git to Manage Source RTL

Software Development I

Object Oriented Programming. Week 1 Part 2 Git and egit

VCS VERSION CONTROL SYSTEMS

Tips on how to set up a GitHub account:

b. Developing multiple versions of a software project in parallel

Version Control with GIT

Midterm Next Week. Last year s midterm (which didn t include remotes):

Improving Your Life With Git

Git. all meaningful operations can be expressed in terms of the rebase command. -Linus Torvalds, 2015

A BASIC UNDERSTANDING OF VERSION CONTROL

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

GUIDE TO MAKE A REAL CONTRIBUTION TO AN OPEN SOURCE PROJECT 1. 1

Version Control. Version Control

Version Control. Collaborating with git. Tim Frasier

Intro to Github. Jessica Young

Fundamentals of Git 1

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

Lab Exercise Git: A distributed version control system

Git Introduction CS 400. February 11, 2018

CS314 Software Engineering Configuration Management

How to git with proper etiquette

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

Topics covered. Introduction to Git Git workflows Git key concepts Hands on session Branching models. Git 2

FEEG Applied Programming 3 - Version Control and Git II

Outline. Introduction to Version Control Systems Origins of Git Git terminology & concepts Basic Git commands Branches in Git Git over the network

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

Version Control with Git ME 461 Fall 2018

CESSDA Expert Seminar 13 & 14 September 2016 Prague, Czech Republic

Introduction to Git and Github

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

Submitting your Work using GIT

Tutorial: Getting Started with Git. Introduction to version control Benefits of using Git Basic commands Workflow

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

Outline. Introduction to Version Control Systems Origins of Git Git terminology & concepts Basic Git commands Branches in Git Git over the network

Introduction to Version Control using Git

Pragmatic Guide to Git

FAQ Q: Where/in which branch do I create new code/modify existing code? A: Q: How do I commit new changes? A:

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

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

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

AIS Grid School 2015

GETTING TO KNOW GIT: PART II JUSTIN ELLIOTT PENN STATE UNIVERSITY

GIT FOR SYSTEM ADMINS JUSTIN ELLIOTT PENN STATE UNIVERSITY

CS 520: VCS and Git. Intermediate Topics Ben Kushigian

Using GitHub and SourceTree to work with DITA TC repositories

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

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

Git. SSE2034: System Software Experiment 3, Fall 2018, Jinkyu Jeong

Eugene, Niko, Matt, and Oliver

Introduction, Instructions and Conventions

How to be a 1337 h4ck3r: Git + Linux

Git(Lab) Tutorial and Hands-On

FPLLL. Contributing. Martin R. Albrecht 2017/07/06

Git GitHub & secrets

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


Effective Software Development and Version Control

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

Computer Science Design I Version Control with Git

Version control with git and Rstudio. Remko Duursma

Using GitHub to Share with SparkFun a

Git version control with Eclipse (EGit) Tutorial

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

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

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

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

Outline. Version Control System (VCS) basics Git terminology & concepts Basic Git commands Branches in Git Git over the network (time permitting)

Transcription:

Git, the magical version control Git is an open-source version control system (meaning, it s free!) that allows developers to track changes made on their code files throughout the lifetime of a project. Git is a great version control tool because it s lightweight and straightforward to use, and it provides incredible compression and speed. Download & Install Git Download Git for your operating system here: http://git-scm.com/downloads When you install Git, nothing will happen. After you install Git, open your terminal application, type gitand hit enter. You should see details about Git, including common commands. NOTE: All Git commands are run in the command line or terminal application, unless you download one of Github s applications. Sign up for GitHub A great place to store your repositories is on GitHub. Setting up an account is free, and you can have as many public repositories as you need. GItHub is also a great way to build a resume for yourself. Often, when developers are applying for jobs, they simply share their GitHub profile link to show potential employers what they ve done.

Gitting Started git init FIRST STEP Before you do anything you have to initialize, or create, your Git repository. You do this with the git init command. It says to your computer Hey this folder I am in, it is now a Git repository. $~ git init git add. SECOND STEP When you are ready to commit your changes you first need to stage them. Use the period (.) to add all directories and files. With your very first commit, you almost always want to add all of your directories and files, not just some of them. $~ git add. git commit -m Write a message here MESSAGE REQUIRED When you have added all of your files, it s time to commit. Committing a collection of changes is like taking a snapshot of your work. These snapshots are what get pushed up to your remote repository. Commits are also handy for rolling back your work to a previous version. $~ git commit m Sometimes its hard to come up with git messages Handy Commands & Files git status As you re working on your project, it s a good idea to periodically run git status to see the changes you ve made. This will show you all files that have been edited, any new files or directories, and any files or directories that have been deleted. It s a *very* good idea to run git status before you add files and commit changes. $~ git status

git diff path/to/file This command shows the changes you ve made to the specified file by diffing your local version with the upstream version. It will show you code that has been added and deleted. It s good practice to run git diff before you add a file for a commit. $~ git diff www/sample/index.html git add path/to/file git add path/to/directory You already know how to add all files and directories with git add., but you can also add files and directories one-by-one. $~ git add www/sample/index.html $~ git add www/sample/css/ git checkout path/to/file If you ve made a complete mess of a file, and it s past the point of saving, you can easily revert back to the remote version of the file by checking it out. $~ git checkout www/sample/index.html git stash If you have a bunch of edits that you need to move out of the way so you can work on other things, you can use stash. Stash is like moving all of your edits to the back burner for awhile. You can run this several times and store many stashes. $~ git stash git stash apply When you re ready to move your code back to the front burner, use git stash apply. This will move everything that has been stashed away, so if you ve run the git stash command multiple times, everything will come along. $~ git stash apply

git stash clear This empties everything out of your stash and gives you a clean slate for a new stash. $~ git stash clear git mv path/to/oldfilename /path/to/newfilename Renames a file. This change has to be committed and pushed to the repo. $~ git mv www/sample/home.html www/sample/index.html git rm path/to/file git rm -r path/to/directory Removes a file or a directory (and everything in it). This change has to be committed and pushed to the repo. $~ git rm www/sample/home.html $~ git rm r www/sample/images/.gitignore Sometimes you may have files or entire directories that you want to keep out of the remote repository while still keeping them in your local repository. The.gitignore file is used to track these files and directories. Add one file or directory per line..htaccess /app/config.rb Remote repositories & GitHub git clone git@github.com:username/reponame.git path/to/local/dir Clones a remote repository to your local environment, into the specified directory. $~ git clone git@github.com:addabjork/sample.git www/sample

git remote add origin git@github.com:username/reponame.git Adds a remote repository to your existing local repository. This allows you to push code up to the remote. $~ git remote add origin git@github.com:addabjork/sample.git git pull origin master BRANCHNAME REQUIRED git pull origin branchname Pulls code from the remote specified branch and merges it into the current local branch. $~ git pull origin refactor git push origin master BRANCHNAME REQUIRED git push origin branchname Pushes code up to the remote specified branch. $~ git push origin refactor git remote -v Checks what remote you are working with and tells you the address. $~ git remote v origin git@github.com:addabjork/sample.git (fetch) origin git@github.com:addabjork/sample.git (push) git remote rm master git remote rm nameofremote Removes the remote specified branch. $~ git remote rm refactor

Branches! Git is designed such that it views your code files like a tree and allows you to do cool things like create a branch where you work on some of the files without affecting the trunk code base until you are sufficiently convinced that the changes you are making are good and won t break the rest of the tree. git checkout -b branchname Does checkout look familiar? In addition to checking out files, git checkout can be used to create and checkout branches. This command creates a new local branch and automatically checks it out. The new branch is in essence a copy of whatever branch you were on before you ran the command. $~ git checkout b v2.0 git checkout branchname Checks out an existing branch. $~ git checkout v2.0 git merge branchname Merge an existing branch into the current branch. First checkout the branch you want to merge into. $~ git checkout master $~ git merge v2.0 git branch -a Shows all existing branches and highlights the current branch. $~ git branch a * master v2.0 remotes/origin/head > origin/master

git branch -d branchname Deletes the specified branch. Danger! Any changes will be lost if you do not first merge this branch into another one. $~ git branch d v2.0 More Information about Git & GitHub For more information about Git, check out the Git documentation. For more information about GitHub, check out GitHub s help guide.