Git Intro Information mostly from Pro Git. Prepare  Start Eclipse, we have a 5-minute exercise later.

Slides:



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

Intro to Version Control Have you ever …? Had an application crash and lose ALL of your work Made changes to a file for the worse and wished you could.
Version Control System (Sub)Version Control (SVN).
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.
om om GIT - Tips & Tricks / git.dvcs git-tips.com
Using subversion COMP 2400 Prof. Chris GauthierDickey.
Low level CASE: Source Code Management. Source Code Management  Also known as Configuration Management  Source Code Managers are tools that: –Archive.
SubVersioN – the new Central Service at DESY by Marian Gawron.
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
1 CSE 390 “Lecture 11” Version control with Git slides created by Ruth Anderson, images from
BIT 285: ( Web) Application Programming Lecture 07 : Tuesday, January 27, 2015 Git.
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.
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.
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 – versioning and managing your software L. Grewe.
Subversion (SVN) Tutorial for CS421 Dan Fleck Spring 2010.
Git A distributed version control system Powerpoint credited to University of PA And modified by Pepper 8-Oct-15.
Prepared by: Steve Teo Contributors: Tong Huu Khiem.
Object-Oriented Software Engineering Using UNIX groups and Subversion Estimated Time: minutes “Unix is user-friendly. It's just very selective about.
Drexel University Software Engineering Research Group Git for SE101 1.
SWEN 302: AGILE METHODS Roma Klapaukh & Alex Potanin.
Team 708 – Hardwired Fusion Created by Nam Tran 2014.
Git Fundamentals Rochelle Terman 13 January 2014.
Prepared by: Steve Teo Contributors: Tong Huu Khiem.
GIT.
Intro to Git presented by Brian K. Vagnini Hosted by.
Version Control and SVN ECE 297. Why Do We Need Version Control?
Lecture 2 Making Simple Commits Sign in on the attendance sheet! credit:
© 2015 by Herb Holyst Introduction to git Cytomics Workshop December, 2015.
1 CSE 303 Lecture 19 Version control and Subversion ( svn ) slides created by Marty Stepp
Subversion (SVN) Tutorial for CS421 Dan Fleck Spring 2010.
Information Systems and Network Engineering Laboratory I DR. KEN COSH WEEK 1.
Git How to 1. Why Git To resolve problems in lab exams (accidental deletions) Use existing Libraries with ease (Statistics and Computer) Prepare undergraduates.
Using Git with collaboration, code review, and code management for open source and private projects. & Using Terminal to create, and push commits to repositories.
BIT 285: ( Web) Application Programming Lecture 07 : Tuesday, January 27, 2015 Git.
Git A distributed version control system Powerpoint credited to University of PA And modified by Pepper 28-Jun-16.
Problem Solving With C++ SVN ( Version Control ) April 2016.
GIT Version control. Version Control Sharing code via a centralized DB Also provides for Backtracking (going back to a previous version of code), Branching.
Basics of GIT for developers and system administrators
CS5220 Advanced Topics in Web Programming Version Control with Git
Subversion Subversion is a brand of version control software that is frequently used to store the code and documentation of a project so as to permit.
Discussion #11 11/21/16.
L – Modeling and Simulating Social Systems with MATLAB
Version Control with Subversion
SVN intro (review).
Version Control.
Setting up Git, GitBash, and GitHub
L – Modeling and Simulating Social Systems with MATLAB
Discussion 11 Final Project / Git.
Version Control overview
CS5220 Advanced Topics in Web Programming Version Control with Git
An introduction to version control systems with Git
Distributed Version Control with git
Akshay Narayan git up to speed with RCS Akshay Narayan
An introduction to version control systems with Git
SIG: Open Week 1: GitHub Tim Choh.
Setting up Git, GitBash, and GitHub
An introduction to version control systems with Git
Git CS Fall 2018.
Version control with Git
Introduction to Version Control with Git
Convert an Eclipse Project to a Git repository and push up to GitHub
Version Control with Git
Version Control with Git and GitHub
Git GitHub.
Presentation transcript:

Git Intro Information mostly from Pro Git

Prepare  Start Eclipse, we have a 5-minute exercise later

Sample Disorganized Project  “Hey, Jane, could you send me a copy of those changes you made last Tuesday?”  “Bob, this function doesn’t work anymore. Did you change something?”  “Sorry, I can’t seem to find those old classes. I guess you’ll just have to re-implement them.”  “OK, we’ve all been working hard for the last week. Now let’s integrate everyone’s work together.”

What is version control?  Basic functionality:  keep track of changes made to files (allows roll-backs)  merge the contributions of multiple developers  Benefits:  facilitates backups  increased productivity (vs manual version control)  encourages experimentation  helps to identify/fix conflicts  makes source readily available – less duplicated effort

Additional benefits  Accountability  who wrote the code?  do we have the rights to it?  Support software engineering  hooks for peer reviews  Software branches  different versions of software need to be maintained, ensure bug fixes shared  Record Keeping  Commit logs may tie to issue tracking system or be used to enforce guidelines

More Benefits  Support Distribution of Work  Telecommuting, outsourcing, open-source projects  Use in conjunction with “good communication habits” – via etc.  Rapid Development (XP/Agile)  Supports frequent refactoring  Helps automate frequent system builds

More Benefits  Employers use version control – and many (maybe most?) use git  Git is professional grade – learn it now!

Command line basics Work without a GUI

Simple command line  Open Git Bash terminal  Where am I??  pwd – print working directory  How do I move around??  cd – change directory  cd c:/csm_classes – change to a specific path  cd.. – change to parent directory.  What files are there?  ls – list  ls - l – list with details

More command line  Use up/down arrow to select/repeat commands  Click on icon in top left corner to change properties of the command window OR edit (e.g., copy, paste)  May be able to use tab completion

Git Basics Summarizing the demo

Centralized Version Control Subversion is like this

Centralized - Differences

Distributed Version Control

Distributed - Snapshots Files are stored by SHA-1 hash rather than filename Stored in git database in compressed format Database is stored on your local machine Must “checkout” from database into working directory to edit In this example, files A, B and C are tracked

Tell Git who you are Update your config, one time only  git config --global user.name “Cyndi Rader”  git config --global user.  git config --global core.editor notepad++  git config --list (or git config –l)

Getting started  Create a Java Project (mine is GitIntro)  cd into project directory  git init  Create a class (mine is HelloGit)

.gitignore  It’s important to tell Git what files you do not want to track  Temp files, executable files, etc. do not need version control (and can cause major issues when merging!)   Example (place in root of repo):  *.class .project .classpath .settings/ repo ignore eclipse exec What is a hidden file?

More.gitignore  # Directories #  /build/  /bin/  target/  # OS Files # .DS_Store  *.class  # Package Files #  *.jar  *.war  *.ear  *.db  # Windows image file caches  Thumbs.db  # Folder config file  Desktop.ini  # OSX .DS_Store .svn  # Eclipse  *.pydevproject .project .metadata  bin/**  tmp/**  tmp/**/*  *.tmp  *.bak  *.swp  *~.nib  local.properties .classpath .settings/ .loadpath  /src/main/resources/rebel.xml

Local Operations Why might you want to stage files?

What’s the status? Nothing tracked yet. get used to reading helpful messages

Let’s track a file git add – tells git to track a file

Also good to commit.gitignore often desirable to have no untracked files

Commit the file to the Git database When you commit, you must provide a comment (if you forget, Git will open a text editor so you can write one).

What if you change the file? Notice more helpful hints Git provides. You could add to the staging area, OR add & commit in one step. Be careful if you add to the staging area and then make more changes – the file can appear as both staged and unstaged. For now, I suggest doing –am

You made some changes – but what did you do? This command compares your working directory with your staging area. These are the changes that are not yet staged.

What if you’ve committed all your changes? diff doesn’t have anything to display

What if I remove a file? File added not committed Now I remove HelloWorld.java from inside Eclipse

removal, continued This removes the file from being tracked. If you’ve already committed, the file is still in the database. -- see github tutorials for info on this.

So what all have I done? There are many useful options for git log.

git log options  Can specify a format, such as:  git log --pretty=oneline  MORE options, see documentation  Can filter, such as:  git log --since=2.weeks  includes filters like –since, --after, --until, --before, --author etc  Can redirect output to file, such as:  git log >> gitlog.txt.

The Big Picture

VERY quick exercise – with a partner  Create a new Java Project  Bring up git Bash  cd to your directory  git init  create a.gitignore  create a new class  add that class (git add src/*)  add.gitignore (git.gitignore)  commit (git commit –m “Initial commit”)

Quick Summary for git bash  cd to your project or source directory  cd = change directory. Example:  cd cs306  cd MyProjects  cd GitDemo  OR cd c:\cs306\MyProjects\GitDemo  ls (shows a list of files in that directory)  git init (creates.git repo)  git add src/* (tracks all files in source directory)  git commit -am “Initial commit” (adds files to repo)  git status (see what files have been modified, etc.)  git diff (see what changes you’ve made to files)  git log (see list of commits)

Advanced example 1 (on your own) Add a file to be tracked, see the status Decide not to track the file – be careful with this!

Advanced Example 2  Use diff to see changes – revert to prior version. BE CAREFUL – you’ll lose all your changes. Be sure this is what you want to do.