Basics of GIT for developers and system administrators

Slides:



Advertisements
Similar presentations
Version Control System (Sub)Version Control (SVN).
Advertisements

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.
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.
Git A distributed version control system 23-Aug-15.
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
Getting Started with GIT. Basic Navigation cd means change directory cd.. moves you up a level cd dir_name moves you to the folder named dir_name A dot.
علیرضا فراهانی استاد درس: جعفری نژاد مهر Version Control ▪Version control is a system that records changes to a file or set of files over time so.
With Mercurial and Progress.   Introduction  What is version control ?  Why use version control ?  Centralised vs. Distributed  Why Mercurial ?
Peter Ogden and Josh Levine.  Motivation  High level overview  Walk through the common operations  How not to break things (too badly)
Git A distributed version control system Powerpoint credited to University of PA And modified by Pepper 8-Oct-15.
Version control Using Git Version control, using Git1.
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
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.
Sofia Event Center May 2014 Martin Kulov Git For TFS Developers.
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.
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.
Git A distributed version control system Powerpoint credited to University of PA And modified by Pepper 28-Jun-16.
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
Version Control Systems
CS5220 Advanced Topics in Web Programming Version Control with Git
Introduction to GitHub
M.Sc. Juan Carlos Olivares Rojas
Primož Gabrijelčič Git for Programmers Primož Gabrijelčič
Version Control Systems
CReSIS Git Tutorial.
Git-Github Safa Prepared for the course COP4331 – Fall 2016.
LECTURE 2: Software Configuration Management
Git Practice walkthrough.
Setting up Git, GitBash, and GitHub
Version control, using Git
CS5220 Advanced Topics in Web Programming Version Control with Git
Version Control with Git and GitHub
Version Control Systems
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
LECTURE 3: Software Configuration Management
SIG: Open Week 1: GitHub Tim Choh.
Setting up Git, GitBash, and GitHub
An introduction to version control systems with Git
Git-Github Tools Prepared for COP4331. Git-Github Tools Prepared for COP4331.
Part 1: Editing and Publishing Files
Source Code Repository
Version control with Git Part II
Git CS Fall 2018.
Version Control System - Git
Version control with Git
Introduction to Git and GitHub
Version Control with Git
Version Control with Git and GitHub
Version/revision control via git
Git Introduction.
Introduction to Git and Github
Git GitHub.
Introduction to The Git Version Control System
Advanced Git for Beginners
Presentation transcript:

Basics of GIT for developers and system administrators GIT Control Basics of GIT for developers and system administrators Jennifer Watson System Engineer University of Maine System NECWIC 2017

Reasons to USE GIT Working on complex code project Working on code from more than one computer Collaborating with others on code or text file Maintain version control on code or file Be able to see when code or configuration files have changed and be able to note/read why it was changed Want to compare or merge different versions Be able to roll back quickly to last known working version after changes break something Distributed copies of code or file provide back up in case of lose

Installing GIT Installed by default on modern *nix Operating systems, but may still want to grab latest version https://git-scm.com/downloads May also consider GUI client SourceTree (free, Mac and Win) https://www.sourcetreeapp.com/

Configuring GIT From a command line: git config –global user.name “FirstName LastName” git config –global user.email “yourname@maine.edu” git config –global color.ui “auto” Mac/linux git config – global core.editor “nano –w” Windows git config –global core.editor “’c:/program files (x86)/Notepad++/notepad++.exe’ –multiInst –notabbar –nosession noPlugin” git config --list

Create a GIT Repository From the command line, Make and/or navigate to the directory/folder for Git to track Type the command: git init

GIT COMMANDS git status git add <file> git commit –m “message” git log --graph git diff git diff –staged git diff HEAD~1 (can substitute 3 version back you want to compare to current version) git diff CommitIHash

GIT commands (continued) git checkout <branch> switch branches git checkout HEAD~1 Reverts to previously committed version can be used to undelete a file git reset HEAD <file> Un-stage file git reset --hard Everything reverted to last commit ! Be careful with reset commands

aka Staging Notice the difference between pull and fetch

Working with remote repositories git clone <url> git remote add <remote> <url for repository on gitLab or ssh link> git remote –v Lists existing remotes git fetch <remote> <branch> Recommend using fetch instead of pull git push <remote> <branch>

Using REMOTES with ssh cd ~/.ssh ssh-keygen Open the rsa.pub file created and copy the contents to your remote repository Begins with ssh-rsa and ends with username@computername

Typical Day with Git Really Good Day git fetch <remote> <feature branch> Or git pull Work on code git status git add <file(s) I worked on/edited> git commit –m “<message about what I fixed with maybe a tag for ticket closure or release>” merge/Resolve differences git push <remote> <feature branch> Submit a Pull Request for approval Not so Good Day git fetch <remote> <feature branch> Work on code Get stuck  git status git add <file(s) I worked on/edited> git checkout –b <remote> <nameForNewBranch> git commit –m “[WIP]<what I was trying to fix and my attempted approach>” Pull Request (aka Merge Request) to teammate Receive feedback/help/resolution --> unstuck  Continue on with Really Good Day workflow

Working with a Team in GIT vs Alone Make sure editor/IDE configured for team agreed upon line lengths Commit often, but generally push working code that fixes an issue or completes feature Make sure to fetch prior to push to then merge in any changes that have occurred on the remote Pull requests allow you to ask someone to review your code for approval, but don’t forget it can also be helpful for asking for help if you get stuck More prescribed branching ALONE Commit often and feel free to push every time as it creates a backup of your code Only need to fetch and merge changes if you had pushed work from another computer to the remote This is when to try out and learn about rebasing (only on private branches) ! Do NOT rebase on public branch

Git Branching Source: https://leanpub.com/git-flow/read

GIT TIPS Create .gitignore file in at root of git respository List files to ignore Can use *.file-extension can still force add exceptions using git add – f file Great for excluding files your IDE may add to your Git tracked folder on your local computer Create hidden file in new folders you create with the following command: touch .gitkeep git cannot track an empty folder, so this is basically a placeholder file

Git for system administrators git init on the folders with important configurations Know if someone else changed them by using git status And what they changed with git log and git diff Explain why you changed them with git commit –m “<reason>” so other admins will know Quickly bring back an earlier working version of the file with git checkout -- <file> Back up those key configurations easily by git push <remote> <branch> Note: git keeps track of changes NOT multiple copies of the file, so it does not take up a lot of space

Learning resources Code Academy https://www.codecademy.com/learn/learn-git https://www.tutorialspoint.com/git/ More on How to Use in a Team https://www.sitepoint.com/getting-started-git- team-environment/ https://git-scm.com/book/en/v2/Git-Basics-Undoing-Things https://www.atlassian.com/git/tutorials/merging-vs-rebasing