Falcons Git Usage Andre Pool Version 2.0 October 2015 / Veldhoven.

Slides:



Advertisements
Similar presentations
Introduction To GIT Rob Di Marco Philly Linux Users Group July 14, 2008.
Advertisements

Git Branching What is a branch?. Review: Distributed - Snapshots Files are stored by SHA-1 hash rather than filename Stored in git database in compressed.
Introduction to Git 2011 F2E Summit Jenny Donnelly, YUI.
om om GIT - Tips & Tricks / git.dvcs git-tips.com
Patterns & practices Symposium 2013 Introducing Git version control into your team Mark
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
Git: Part 1 Overview & Object Model These slides were largely cut-and-pasted from tutorial/, with some additions.
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,
Git. What’s Git? A British swear A Distributed Version Control System Developed in 2005 by Linus Torvalds for use on the Linux Kernel Git Logo by Jason.
Introduction to Version Control with SVN & Git CSC/ECE 517, Fall 2012 Titus Barik & Ed Gehringer, with help from Gaurav.
Subversion. What is Subversion? A Version Control System A successor to CVS and SourceSafe Essentially gives you a tracked, shared file system.
علیرضا فراهانی استاد درس: جعفری نژاد مهر Version Control ▪Version control is a system that records changes to a file or set of files over time so.
Peter Ogden and Josh Levine.  Motivation  High level overview  Walk through the common operations  How not to break things (too badly)
Git – versioning and managing your software L. Grewe.
1 Introductory Notes on the Git Source Control Management Ric Holt, 8 Oct 2009.
Git A distributed version control system Powerpoint credited to University of PA And modified by Pepper 8-Oct-15.
ITEC 370 Lecture 16 Implementation. Review Questions? Design document on F, feedback tomorrow Midterm on F Implementation –Management (MMM) –Team roles.
Drexel University Software Engineering Research Group Git for SE101 1.
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.
SWEN 302: AGILE METHODS Roma Klapaukh & Alex Potanin.
Team 708 – Hardwired Fusion Created by Nam Tran 2014.
Git : Part 2 Checkout, Add, Commit These slides were largely cut-and-pasted from tutorial/, with some additions.
Introduction to Version Control with Git CSC/ECE 517, Fall 2014 A joint project of the CSC/ECE 517 staff, including Titus Barik, Gaurav Tungatkar, Govind.
Git overview for RoboCup Andre Pool, September 2015.
GIT.
Intro to Git presented by Brian K. Vagnini Hosted by.
Page 1 TBD 12/08/2014 Formation GIT Laurent Kappel Groupe SII 65, rue de Bercy Paris Tél : Fax :
12 CVS Mauro Jaskelioff (originally by Gail Hopkins)
Introduction to Git Yonglei Tao GVSU. Version Control Systems  Also known as Source Code Management systems  Increase your productivity by allowing.
GIT: What, how and why ? Part 1: Basics. What do I know about git? Started using it for experiments on April 2009 Moved all voms development on git on.
Thanks to our Sponsors! Community Sponsor Yearly Sponsor Marquee Sponsor.
Git How to 1. Why Git To resolve problems in lab exams (accidental deletions) Use existing Libraries with ease (Statistics and Computer) Prepare undergraduates.
Git workflows: using multiple branches for parallel development SE-2800 Dr. Mark L. Hornick 1.
Git A distributed version control system Powerpoint credited to University of PA And modified by Pepper 28-Jun-16.
Getting Started with Git Presented by Jim Taylor Rooty Hollow, Owner Verizon Wireless, Senior Programmer/Analyst Git User for 6 years.
Git for bzr users October Aurélien Gâteau An attempt at making you comfortable when you have to work with a git repository.
Backing up a machine with git
GIT: (a)Gentle InTroduction Bruno Bossola. Agenda About version control Concepts Working locally Remote operations Enterprise adoption Q&A.
KIT – University of the State of Baden-Wuerttemberg and National Research Center of the Helmholtz Association STEINBUCH CENTRE FOR COMPUTING - SCC
CS5220 Advanced Topics in Web Programming Version Control with Git
Introduction to GitHub
Introduction to Version Control with Git
I Don’t Git It: A beginner’s guide to git Presented by Mathew Robinson
Version Control Systems
11 Version control (part 2)
CReSIS Git Tutorial.
LECTURE 2: Software Configuration Management
Git Practice walkthrough.
File Version Control System
Learning GIT CodicePlastico.com.
CS5220 Advanced Topics in Web Programming Version Control with Git
Git branches and remotes
An introduction to version control systems with Git
Distributed Version Control with git
Akshay Narayan git up to speed with RCS Akshay Narayan
LECTURE 3: Software Configuration Management
The Big Picture
Using Github.
Version Control System - Git
Version control with Git
Git Fundamentals.
Git Introduction.
Git GitHub.
Introduction to The Git Version Control System
Advanced Git for Beginners
Presentation transcript:

Falcons Git Usage Andre Pool Version 2.0 October 2015 / Veldhoven

Contents Why git Git basics Rules Part 1: Example add/commit/push/pull Part 2: Example branch/merge Part 3: Undo Way of working

Why git Performance State before merge from remote is stored Non blocking workflow No network connection needed to continue – Distributed version control system No tampering possible / database assurance Local commits are managed as small branches Easy to mere Easy to compare everything with everything – workspace, branch, version,..

Git basics Lots of options / Overwhelming Steep learning curve Fortunately you are up and running with only 16 commands Start simple Skip explaining underlying git database structure (interesting but not essential to know for day to day usage)

4 stages Working directory – sandbox Index = stage – proposed next – commit snapshot HEAD – last commit snapshot, – Local repository Remote – e.g. shared remote – repository

Most commonly used git commands 1 of 2 addAdd file contents to the index branchList, create, or delete branches checkoutCheckout a branch or paths to the working tree cloneClone a repository into a new directory commitRecord changes to the repository diffShow changes between commits, commit and working tree, etc. fetchDownload objects and refs from another repository logShow commit logs

Most commonly used git commands 2 of 2 mergeJoin two or more development histories together mvMove or rename a file, a directory, or a symlink pullFetch from and merge with another repository or a local branch pushUpdate remote refs along with associated objects rebaseForward-port local commits to the updated upstream head resetReset current HEAD to the specified state rmRemove files from the working view and from the index statusShow the working tree status tagCreate, list, delete or verify a tag object signed with GPG

DVCS Every working directory is a complete repository Commit on this local repository (fast) Be careful with large files (will be around in every working directory for ever for every different version) Do not forget to synchronize with a shared location before deleting working directory (a commit stays in the working directory)

Rules No large and or generated files in code repository! Clean code repository: – High performance – Fast clone – Limited disk space required for each project (clone) If required put large files in data repository git rm myLargeFile Removes the file from the workspace, but NOT from the repository!

Setup: ~./gitconfig file [user] name = John Doo = [alias] coa = commit -a -m st = status graph = log --graph --abbrev-commit --pretty=oneline logp = log --abbrev-commit --pretty=oneline logf = log --follow

Part 1 The basics

Git Basic Example add/commit/push/pull Basic commands which cover the day to day usage Create repository User Barry does “things” User John does “things” Conflict Solve conflict GUI view

Basic Example Create (shared/central) repository git init --bare ~/tmp/my_rep.git Initialized empty shared Git repository in /home/apool/tmp/my_rep.git/ That’s all --barerepository without “working directory” Note1: the option “--shared” can be used when the repository is shared amongst several users, but this adds restrictions e.g. wrong pushed commits can not be removed! Note2: most git users will never need to create a repository

Basic Example user Barry clone git clone ~/tmp/my_rep.git barry Cloning into 'barry'... warning: You appear to have cloned an empty repository. Done. So now barry has its own “working directory” with full blown repository

Basic Example user Barry status cd barry echo "barry his first line" > readme.txt git status # On branch master # # Initial commit # # Untracked files: # (use "git add..." to include in what will be committed) # # readme.txt nothing added to commit but untracked files present (use "git add" to track)

Basic Example user Barry add git add. git status # On branch master # # Initial commit # # Changes to be committed: # (use "git rm --cached..." to unstage) # # new file: readme.txt #

Basic Example user Barry commit & push git commit -m "barry his first line" [master (root-commit) 33a9791] initial commit from barry 1 file changed, 1 insertion(+) create mode readme.txt git push Counting objects: 3, done. Writing objects: 100% (3/3), 233 bytes, done. Total 3 (delta 0), reused 0 (delta 0) To /home/apool/tmp/my_rep.git * [new branch] master -> master Note: the hashes 33a9791 is not from the file but from the full repository !

Basic Example user John clone/commit/push git clone ~/tmp/my_rep.git john cd john echo "john his first line" >> readme.txt git commit -a -m "john his first line" git push Note: skipped the “git add command”

Basic Example user Barry merge from John cd ~/tmp/barry git pull remote: Counting objects: 8, done. remote: Compressing objects: 100% (3/3), done. remote: Total 6 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (6/6), done. From /home/apool/tmp/my_rep 33a master -> origin/master Updating 33a Fast-forward readme.txt | file changed, 3 insertions(+)

Basic Example create conflict cd ~/tmp/barry echo "barry his conflicting line" >> readme.txt git commit -a -m "barry his conflicting line" No push here ! cd ~/tmp/john echo "john his conflicting line" >> readme.txt git commit -a -m "john his conflicting line" Now “barry” repository and “john” repository different data on the same line ! git push Now central repository and “barry” repository different data on the same line !

Basic Example outdated local repository cd ~/tmp/barry git push To /home/apool/tmp/my_rep.git ! [rejected] master -> master (already exists) error: failed to push some refs to '/home/apool/tmp/my_rep.git' hint: Updates were rejected because the destination reference already exists hint: in the remote. Barry cannot push his repository because the HEAD of the remote master has moved to a newer commit. Barry needs first to get his local repository to move to the HEAD of the remote master. (git pull => fetch + merge)

Basic Example update / experience conflict git pull remote: Counting objects: 5, done. remote: Compressing objects: 100% (2/2), done. remote: Total 3 (delta 1), reused 0 (delta 0) Unpacking objects: 100% (3/3), done. From /home/apool/tmp/my_rep 1ed438d..ac6682c master -> origin/master Auto-merging readme.txt CONFLICT (content): Merge conflict in readme.txt Automatic merge failed; fix conflicts and then commit the result.

Basic Example view merge fail result cat readme.txt barry his first line john his first line <<<<<<< HEAD barry his conflicting line ======= john his conflicting line >>>>>>> ac6682c38e131e9653ca14045c8f1011a509d35c

Basic Example manual resolve conflict edit / correct readme.txt to solve conflict git commit -a -m "barry resolved merge manual" [master 555baa9] barry resolved merge manual git push Counting objects: 10, done. Delta compression using up to 12 threads. Compressing objects: 100% (4/4), done. Writing objects: 100% (6/6), 634 bytes, done. Total 6 (delta 1), reused 0 (delta 0) To /home/apool/tmp/my_rep.git ac6682c..555baa9 master -> master

Basic Example check if john got merge cd ~/tmp/john git pull Updating ac6682c..555baa9 Fast-forward readme.txt | git log --abbrev-commit --pretty=oneline bb80fe1 barry resolved merge manual f99d0d9 barry his conflicting line e1f3f4f john his conflicting line 60a2fb1 barry his second line f604bf7 barry his first line Note: above SHA1 keys are not correct in this example

Basic Example: tag Pointer to specific hash Create git tag v1.0 git push tag Show git tag v1.0 Tag Conventions: to be defined A tag can afterwards be moved to a different hash !!

Basic Example Final: gitk To better understand how to use git Use gitk for a nice history view But use command line commands for control gitk

Basic Example: diff git diff my_branch master index = stage

Basic Example.gitignore file git status Changed files = want to see Untracked files – Forgotten files = want to see – Created files:.o files, … = do not want to see Might cause missing the files we want to see Possible to create everywhere a.gitignore file with blocking rules *.o *.bak tmp/* build/*

Part 2 Branches

Branch Example: Overview John creates branch Modify file Commit Push branch remote Barry gets Johns branch Merges branch in master Barry removes local and remote branch of John Rebase

Branch Example: Create & List at John Create branch “john_br” ( = copy of current master ) git checkout -b john_br List both local and remote-tracking branches git branch -a * john_br master remotes/origin/HEAD -> origin/master remotes/origin/master

Branch Example: Modify, commit and push echo "john add line branch john_br" >> readme.txt git commit -a -m "add line branch john_br" For the first time explicit push the new branch in the remote!! git push --set-upstream origin john_br To /home/apool/tmp/my_rep.git * [new branch] john_br -> john_br

Branch Example: View at Barry Check if barry can see the remote branch of john ~/tmp/barry git pull From /home/apool/tmp/my_rep * [new branch] john_br -> origin/john_br Already up-to-date. git branch -a * master remotes/origin/john_br remotes/origin/master

Branch Example: Barry merges John his branch Barry merges the remote branch in his local master branch git merge origin/john_br master Updating bb80fe1..d3c2d2d Fast-forward readme.txt | file changed, 1 insertion(+) Barry pushes the merge results from his local master to the remote git push To /home/apool/tmp/my_rep.git bb80fe1..d3c2d2d master -> master

Branch Example: Work on John his branch You do not need to merge: You can also work on john his branch You can cherry pick from john his branch You can checkout differences between master and john his branch … git checkout john_br Branch john_br set up to track remote branch john_br from origin. Switched to a new branch 'john_br' git branch -a * john_br master remotes/origin/john_br remotes/origin/master

Branch Example: Manage branches Diff between branches (works also for dirs and files) git diff origin/john_br master Toggle between branches git checkout john_br git checkout master Delete local branch git branch -D john_br Delete remote branch git branch -rd origin/john_br ? Git push probably needed? Other “users” need to use remote prune (instead of pull) to remove the deleted remote branch john_br from their remote list git remote prune origin

Rebase Move split moment to current master git checkout john_br git merge master Often this makes the git history cleaner (branches) Fast Forward

Part 3 Undo

Undo Example Correct commit message Look at previous state Remove commit

Undo Example: replace last commit message git commit -a -m "wrong message" [master 9a20789] wrong message 1 file changed, 1 insertion(+) git log --abbrev-commit --pretty=oneline -n 2 9a20789 wrong message d3c2d2d john added line to branch john_br git commit --amend -m "good message" [master 9bd6247] good message 1 file changed, 1 insertion(+) git log --abbrev-commit --pretty=oneline -n 2 9bd6247 good message d3c2d2d john added line to branch john_br

Undo Example: step back 2 commits git log --abbrev-commit --pretty=oneline -n 4 d3c2d2d john added line to branch john_br bb80fe1 barry resolved merge manual f99d0d9 barry his conflicting line e1f3f4f john his conflicting line git checkout HEAD~2 Note: checking out 'HEAD~2'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout. HEAD is now at f99d0d9... barry his conflicting line

Undo Example: status git log --abbrev-commit --pretty=oneline -n 2 f99d0d9 barry his conflicting line e1f3f4f john his conflicting line We are not on branch master anymore git branch -a * (no branch) master remotes/origin/master

Undo Example: return to master git checkout master Previous HEAD position was f99d0d9... barry his conflicting line Switched to branch 'master‘ git log --abbrev-commit --pretty=oneline -n 4 d3c2d2d john added line to branch john_br bb80fe1 barry resolved merge manual f99d0d9 barry his conflicting line e1f3f4f john his conflicting line

Undo Example: remove last local commit git commit -a -m "bad commit" [master 03fbf2a] bad commit 1 file changed, 1 insertion(+) git log --abbrev-commit --pretty=oneline -n 2 03fbf2a bad commit 9bd6247 barry his second line git reset --hard HEAD^ HEAD is now at 9bd6247 barry his second line git log --abbrev-commit --pretty=oneline -n 1 9bd6247 barry his second line

Way of working Check if no dangling file git status Check diff before commit git diff – disabled crucial part of code? – added debug code? Use one explaining one liner, starting with module name git commit -a -m "vision: fixed error in ball size calculation" git pull Correct merge if auto merge failed git push

Pit-holes git commit –m “my story“ But did not add files, so nothing will be committed forget to do git push before removing working directory (including repository) forget a push of another branch before removing working directory forget to push newly created branches to the remote Think you are working on master branch

Good luck