Git Introduction CS 400. February 11, 2018

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

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

Introduction to Git. Database Systems DataLab, CS, NTHU Spring, 2018

Git for Version Control

Version Control with GIT

Version Control: Gitting Started

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

Submitting your Work using GIT

Git tutorial. Katie Osterried C2SM. October 22, 2015

GETTING STARTED WITH. Michael Lessard Senior Solutions Architect June 2017

Version control with Git.

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

Overview. 1. Install git and create a Github account 2. What is git? 3. How does git work? 4. What is GitHub? 5. Quick example using git and GitHub

A Brief Git Primer for CS 350

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

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

CS314 Software Engineering Configuration Management

Software Development I

Basics of Git GitHub

AIS Grid School 2015

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

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

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:

Revision control. INF5750/ Lecture 2 (Part I)

Software Project (Lecture 4): Git & Github

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

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

CS 390 Software Engineering Lecture 4 - Git

Θερινό Σχολείο, Ιουλίου git. Αχιλλέας Πιπινέλης. Μονάδα Αριστείας ΕΛ/ΛΑΚ ΤΕΙ Αθήνας

Introduction to Git and Github

Object Oriented Programming. Week 1 Part 2 Git and egit

Lecture 6 Remotes. Sign in on the attendance sheet!

Algorithm Engineering

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

Assumptions. GIT Commands. OS Commands

Barry Grant

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

Git & Github Fundamental by Rajesh Kumar.

FEEG Applied Programming 3 - Version Control and Git II

A BASIC UNDERSTANDING OF VERSION CONTROL

Version Control Systems

Git. Presenter: Haotao (Eric) Lai Contact:

Version Control. Second level Third level Fourth level Fifth level. - Software Development Project. January 17, 2018

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

Computer Science Design I Version Control with Git

Github/Git Primer. Tyler Hague

VCS VERSION CONTROL SYSTEMS

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

Visualizing Git Workflows. A visual guide to 539 workflows

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

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

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

Tizen/Artik IoT Practice Part 4 Open Source Development

Effective Software Development and Version Control

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

Laboratorio di Programmazione. Prof. Marco Bertini

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

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

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

Software Revision Control for MASS. Git Installation / Configuration / Use

Chapter 5. Version Control: Git

GIT FOR SYSTEM ADMINS JUSTIN ELLIOTT PENN STATE UNIVERSITY

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

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

Git. Ľubomír Prda. IT4Innovations.

CSE 391 Lecture 9. Version control with Git

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

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

A Practical Introduction to Version Control Systems

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

Managing Network Configurations with Git and GitLab

Revision Control and GIT

Tutorial 2 GitHub Tutorial

TDDC88 Lab 4 Software Configuration Management

b. Developing multiple versions of a software project in parallel

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

Git, the magical version control

Having Fun with Social Coding. Sean Handley. February 25, 2010

Fundamentals of Git 1

Setting up GitHub Version Control with Qt Creator*

DEVNET Introduction to Git. Ashley Roach Principal Engineer Evangelist

How to be a git. Dominic Mitchell

Lab Exercise Git: A distributed version control system

Git: Distributed Version Control

Basic git. Interactive.

Use git rm to remove files from workspace

Improving Your Life With Git

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

A Practical Introduction to git

INET

Version Control with Git

Git(Lab) Tutorial and Hands-On

Version Control. Version Control

Crash Course in C++ R F L Evans. www-users.york.ac.uk/~rfle500/

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

GIT VERSION CONTROL TUTORIAL. William Wu 2014 October 7

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

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

Source Code Management wih git

Git. It is easy to shoot your foot off with git, but also easy to revert to a previous foot and merge it with your current leg.

Transcription:

Git Introduction CS 400 February 11, 2018 1 Introduction Git is one of the most popular version control system. It is a mature, actively maintained open source project originally developed in 2005 by Linus Torvalds, the famous creator of the Linux operating system kernel. 2 Installation Please follow following link for installing git on your system. https://www.atlassian.com/git/tutorials/install-git 3 Getting Started 3.1 Configuration You can run below commands with your name and email id to associate all your git repositories with this name and email id. git config --global user.name "your name" git config --global user.email "your email id" 3.2 Initialization To initialize a Git repository, go to your directory where you want to edit/create your files. Then use the following command: git init Now all the files that you create within this directory can be version controlled using some simple commands. You will learn these commmands below one by one. 1

3.3 Checking the status To see what the current state of our project is, use: git status Current status means which files you have modified since your last commit and which files are in the staging areas, ready to be committed. (You will learn about staging are and commit in further sections.) 3.4 Adding changes To tell Git to start tracking changes made to your files (by committing them), we first need to add it to the staging area by using the following command: git add filename.txt You can think of staged files as files that are ready to be committed and git has been made aware of this. The staging area is essentially a holding area for changes that will be committed when you next do git commit. Staging helps you split up one large change (that you want to make to your source codes,especially in multiple files) into multiple independent commits. 3.5 Committing To store our staged changes we run the following command with a message describing what we ve changed. git commit -m "Add comment here" You should add meaningful comments. When you go back to some earlier version of your code, comments will help you in tracking the changes efficiently. Example: git commit -m "Implemented insertion and deletion" Committed means that the data is safely stored in your local database. You should ideally commit any important conceptual changes in your files/source code. Following figure indicates three areas(conceptual) where your files are stored. 3.6 Adding all changes You can add all the new files or multiple files using following commands. git add *.txt Above command will add all the files with txt extension. git add. Last command will add all the files in your working directory to the staging area. 2

Figure 1: Git terminologies 3.7 History To track all the changes you have committed so far, you can use the following command: git log Figure 2: Example output of git log command 3.8 Remote Repositories Till now all the files your were saved on the local machine. We call it local repository. You can also save the exact copy of files (with all commit history) at any remote location. We call that remote repository. Github is a free platform where you can save your repository. To push our local repo to the GitHub server we ll need to add a remote repository by using following command. 3

git remote add origin repositorylink Example: git remote add origin git@github.com:sonuagr/gitdemo1.git origin is the name of the remote. You can use any name, but origin is the conventionally used name. You will get the repository link once you create a new repository on Github. 3.9 Pushing Remotely Below command tells Git where to push our commits. git push -u origin master The -u tells Git to remember the parameters, so that next time we can simply run git push and Git will know what to do. origin is the name of the remote, you want to push your repository to. master is the default name of the local branch. 3.10 Pulling Remotely After you have pushed your files to the remote repository, your collaborators can make changes to those files and commit/push those changes. To get the latest copies of the files to your local repositories, you can use following command: git pull origin master 3.11 Differences After you have made some changes in your working area, you might want to know what are the changes you did after your last commit. You can do so using below command: git diff HEAD Note: The HEAD is a pointer that holds your position within all your different commits. By default HEAD points to your most recent commit, so it can be used as a quick way to reference that commit. To view difference between HEAD and staging area, use: git diff --staged You can also view the differences between Stage and working directory using: git diff 4

3.12 Resetting the stage If you want to remove any file from the staging area i.e., unstage the file, you can use: git reset filename.txt 3.13 Undo Files can be changed back to how they were at the last commit by using the command: git checkout -- filename.txt 3.14 Branching out You can create a new branch anytime to experiment with your files. To create a new branch, use the following command. git branch expt1branch 3.15 Switching branches When you create a new branch, you do not automatically switch to new branch. You are still at the previously checked-out branch. You need to use following command to switch to a new branch. git checkout expt1branch 3.16 Switching back to master You can switch back to the master branch (default branch when you initialize a git directory) using below command. This is similar to checking out any branch. git checkout master 3.17 Preparing to merge You can merge any two branches. To merge your master branch with the new branch, use following command. git merge checkout expt1branch Note that master is the checked out branch at this moment. Basically, above command will merge the new branch name branch with currently checked out branch. Also, new branch name will be merged into the master branch. Automatic merging will occur only if there are no conflicts between the two branched. Otherwise you will get warning, and you will have to resolve the conflicts manually. 5

3.18 Keep Things Clean To delete any branch, use below command. git branch -d expt1branch 4 References You can also use following resources to learn basics of git and github. 1. https://try.github.io/levels/1/challenges/1 2. https://www.youtube.com/watch?v=swyqp7iy_tc 3. udacity.com (Course Name: How to Use Git and GitHub?) This tutorial has been created by Sonu Agarwal for CS 400 course. You can send email at sonu@cs.wisc.edu for any clarification or reporting any error. 6