CReSIS Git Tutorial.

Slides:



Advertisements
Similar presentations
1 CSE 390 “Lecture 11” Version control with Git slides created by Ruth Anderson, images from
Advertisements

Introduction to Git and Github Joshua imtraum.com.
Distributed Version Control. Image stolen from which is really good, go read it.  Old-school version control.
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.
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.
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.
Team 708 – Hardwired Fusion Created by Nam Tran 2014.
GIT.
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.
Installing git In Linux: sudo apt-get install git In Windows: download it from run the setuphttp://git-scm.com/download/win.
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.
Jun-Ru Chang Introduction GIT Jun-Ru Chang
GIT Version control. Version Control Sharing code via a centralized DB Also provides for Backtracking (going back to a previous version of code), Branching.
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
KIT – University of the State of Baden-Wuerttemberg and National Research Center of the Helmholtz Association STEINBUCH CENTRE FOR COMPUTING - SCC
Version Control Systems
Basics of GIT for developers and system administrators
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
11 Version control (part 2)
Git-Github Safa Prepared for the course COP4331 – Fall 2016.
Git Practice walkthrough.
CS/COE 1520 Recitation Week 2
Setting up Git, GitBash, and GitHub
Version Control overview
File Version Control System
Git branches and remotes
ALICE-Juniors Meeting
Version Control Systems
Storing, Sending, and Tracking Files Recitation 2
Concurrent Version Control
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
The Big Picture
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.
Version control with Git
Source Code Repository
Version control with Git Part II
Version Control System - Git
Version control with Git
Git started with git: 2018 edition
Version Control with Git and GitHub
GitHub 101 Using Github and Git for Source Control
Version/revision control via git
Git GitHub.
Introduction to The Git Version Control System
Advanced Git for Beginners
Presentation transcript:

CReSIS Git Tutorial

CReSIS Git Tutorial Git: a distributed version control system Topics Distributed means that each person holds the entire repository locally This means you have a local copy of all versions of your project files Topics Installation Configuration (git config …) How to get a copy of another repository (git clone) Get updates from another repository (git pull) Commit your changes (git commit) Send your commits to another repository (git push) Other common tasks Windows Server Remote Git SSH Access Link a repository for a different project into a repository https://www.atlassian.com/git/tutorials/ https://git-scm.com/doc <-- Git Home Page

Installation Install “git for windows” Install “TortoiseGit” IMPORTANT: Choose all the default settings except for the ones described on the next few slides. Install “TortoiseGit” Choose all the default settings. If software is not available from the “Software Center”, you will need to email helpdesk to have them install it.

Installation: Git For Windows Normal Installation Field Installation Where Windows SSH Server Will Be Required

Installation: Git For Windows Do not commit files with CRLF (carriage return – line feed).

Configuration (git config …) Your global git configuration settings are stored in your user directory in the “.gitconfig” file. Windows: C:\Users\USERNAME\.gitconfig Linux: /users/USERNAME/.gitconfig/ git setup: You can edit your .gitconfig file using the “git config” command: git config --global color.ui auto Or you can just edit it directly: [user] name = FIRST LAST email = KU_EMAIL_ADDRESS [alias] lgb = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset%n' --abbrev-commit --date=relative --branches [color] ui = auto

Configuration (git config …): TortoiseGit Remember password Username and Email Shortcut to edit “.gitconfig”

How to get a copy of another repository (git clone) For KU CReSIS accounts, “cd ~/scripts/” first Using TortoiseGit you right click in your \users\USERNAME\documents\scripts directory and choose “git clone” and then paste above address into URL field. git checkout dev Switch to branch “dev”. To create a new repository in any directory: git init

How to get a copy of another repository (git clone) You can git clone from any repository. Three ways to specify the repository: https: (must have server that supports this) https://github.com/CReSIS/OPS.git https://git.cresis.ku.edu/dangermo/cresis- toolbox.git ssh: (any machine running ssh) paden@ssh.cresis.ku.edu:443:scripts/cresis- toolbox/ git@github.com:CReSIS/OPS.git The file path on the remote machine is given after the colon. file path: E:\Documents\scripts\cresis-toolbox

How to get a copy of another repository (git clone) When you clone a repository you get everything for the specified branch. To pass changes back and forth between repositories we use the “push” and “pull” commands. You just have to tell git where the repository exists (can be an ssh server, https server, or a directory on a file system). Only committed changes can be pushed and pulled. If you make changes that you want to share or a particular version (snapshot of all files) that you may want to refer back to, you “commit” your changes. If another person commits a file you are trying to commit, you will have to merge in their changes and commit this merge before you are allowed to push your commits.

How to get a copy of another repository (git clone) Change your active branch to “dev”

Get updates from another repository (git pull) Gets any new commits and adds them to your repository Without arguments, it assumes: “origin” for the remote repository (short cut for the original repository that you cloned from… although you can change it manually too). Current active branch You can git pull from any repository. See previous page on cloning to see how to specify other repositories.

Get updates from another repository (git pull) Gets any new commits and adds them to your repository Without arguments, it assumes: “origin” for the remote repository (short cut for the original repository that you cloned from… although you can change it manually too). Current active branch You can git pull from any repository. See previous page on cloning to see how to specify other repositories.

Get updates from another repository (git pull) Gets any new commits and adds them to your repository Without arguments, it assumes: “origin” for the remote repository (short cut for the original repository that you cloned from… although you can change it manually too). Current active branch You can git pull from any repository. See previous page on cloning to see how to specify other repositories.

Git Commit: “Stage” or select which files you want to commit. TortoiseGit: Staging and committing are all one step and the graphical user interface is intuitive. Make sure to select only the files you want to commit. Check diff on each file by double clicking on the file and opening in TortoiseGitMerge. Command line: git add FILENAME, git add -u (adds all tracked files) git add –i Interactive mode. Example is to add all untracked files. First you select which files you want. For example “a” for untracked. Then select which of those you want to add. For example, “*” for all. Then quit “q”. git status Tells you which files you have added git reset FILENAME Unstages a file git reset Unstages all files git commit

Git Commit: “Stage” or select which files you want to commit. TortoiseGit: Staging and committing are all one step and the graphical user interface is intuitive. Make sure to select only the files you want to commit. Check diff on each file by double clicking on the file and opening in TortoiseGitMerge. Command line: git add FILENAME, git add -u (adds all tracked files) git add –i Interactive mode. Example is to add all untracked files. First you select which files you want. For example “a” for untracked. Then select which of those you want to add. For example, “*” for all. Then quit “q”. git status Tells you which files you have added git reset FILENAME Unstages a file git reset Unstages all files git commit

Send your commits to another repository (git push) Just like git pull only you are sending your commits to another repository. In fact, it is almost identical to having the other repository do a git pull from your repository.

Send your commits to another repository (git push) Just like git pull only you are sending your commits to another repository. In fact, it is almost identical to having the other repository do a git pull from your repository.

Other: Undo changes Undo commits from “mybranch” git checkout mybranch If you have not already pushed the commits, you can just delete them completely from the history: git reset --hard HEAD~2 Moves back 2 commits and removes all working directory changes HEAD is a short cut to the most recent commit on your checked out branch If you have pushed the commits you are trying to undo, then you should create a new commit with the changes removed: git revert --no-commit HEAD~2..HEAD Reverts last 3 commits git commit --message “Revert last two commits” If you have pushed a commit that was a merge that you are trying to undo, then you need to choose the correct parent to revert to (use “git log” to see the list of parents): $ git log commit c66e84975765bc5274a649c393187c25a3ba5bde Merge: b75a504 e403d46  PARENTS ARE LISTED HERE git revert -m 1 --no-commit HEAD  -m 1 chooses “b75a504” Just undo working directory changes (there is no way to undo these commands with git) git reset --hard HEAD # Resets the whole repository git checkout -- FILE # Resets a specific file git clean -d –f # Removes untracked files and directories Unstage Files git reset HEAD FILENAME git reset Unstages all files Amend a previous commit git commit --amend

Other: Stashing “Stashing” changes so you can switch branches even though your working directory is in a dirty state (you have modified tracked files and staged changes). Stashing is necessary for a “git pull” which brings in commits on files which conflict with your modifications. TortoiseGit: Usually just use “Stash Save” and “Stash Pop” git stash Stashes git stash list git stash apply stash@{1} Applies changes from your stash git stash drop stash@{1} Drops a particular stash (do this when you no longer need it) git stash show -p stash@{0} | git apply –R Undoes a stash (-R applies in reverse … which means it undoes the changes) “Show -p” prints the changes associated with the particular stash to stdout

Other: Stashing “Stashing” changes so you can switch branches even though your working directory is in a dirty state (you have modified tracked files and staged changes). Stashing is necessary for a “git pull” which brings in commits on files which conflict with your modifications. TortoiseGit: Usually just use “Stash Save” and “Stash Pop” git stash Stashes git stash list git stash apply stash@{1} Applies changes from your stash git stash drop stash@{1} Drops a particular stash (do this when you no longer need it) git stash show -p stash@{0} | git apply –R Undoes a stash (-R applies in reverse … which means it undoes the changes) “Show -p” prints the changes associated with the particular stash to stdout

Other: Branching To create a new branch: git checkout -b newbranch Short for git branch newbranch; git checkout newbranch; git fetch origin NEWBRANCH git checkout NEWBRANCH; git merge master OR git checkout master; git merge NEWBRANCH OR git pull origin rss (pulls rss branch and merges it) git branch -d NEWBRANCH Works if fully merged. To override protection use -D: git branch -D NEWBRANCH

Resolving Conflicts TortoiseGit: Use TortoiseMerge Linux: Just edit the files that are conflicted and then commit them. Conflicted files will have conflict blocks in them which have to be manually removed/edited.

Windows Server Install “Bitvise ssh” Commands to access it from Linux Server assuming “10.0.0.10” is the IP address of your Windows Server: git clone awi@10.0.0.10:cresis-toolbox.git git remote add origin awi@10.0.0.10:cresis-toolbox.git git push git pull To push changes to the Windows Server, you will need to checkout a different branch on the windows server before it will allow pushes to it.

Windows Server: Create user

Windows Server: SSH Server Settings

Windows Server: SSH Server Settings

Windows Server: SSH Server Settings

Windows Server: SSH Server Settings

Windows Server: Settings of toolbox folder

Windows Server: Verify Path Set

Remote Git SSH Access Generate Key ssh-keygen -t rsa -C paden@ku.edu Save the key in the default location ~/.ssh/id_rsa Add public key (cat ~/.ssh/id_rsa.pub) on git.cresis.ku.edu Gitlab website Add the key here: DashboardProfile SettingsSSH Keys git.cresis.ku.edu ssh server opened to the world on port 62: git remote add origin ssh://git@git.cresis.ku.edu:62/dangermo/cresis- toolbox.git

Remote Git SSH Access Steps to setup tunnel: no longer required since git server is setup on port 62 Setup Tunnel to SSH Server ssh -L12001:git.cresis.ku.edu:22 -p 443 paden@ssh.cresis.ku.edu Create ~/.ssh/config file with the following contents: Host git.cresis.ku.edu HostName localhost User git Port 12001 IdentityFile ~/.ssh/id_rsa git clone git@git.cresis.ku.edu:dangermo/cresis-toolbox.git

Link a repository for a different project into a repository git submodule add git@git.cresis.ku.edu:mxu/cresis-music-3d.git cresis- toolbox/+tomo/optim_tracker/ If cloning a repository with submodules, you will need to run: git submodule init git submodule update OR just do git clone --recursive To grab a new commit/version from the submodule: git submodule update --remote To specify a branch besides master git config –f .gitmodules submodule.cresis-music-3d.branch dev Then git submodule update –remote If you switch to a branch without the submodule and need to remove it: git clean –fdx To remove a submodule: git submodule rm optim_tracker