699DR git/github Tutorial

Similar documents
Software Development I

Tips on how to set up a GitHub account:

Github/Git Primer. Tyler Hague

Visualizing Git Workflows. A visual guide to 539 workflows

Tizen/Artik IoT Practice Part 4 Open Source Development

CS314 Software Engineering Configuration Management

KTH Royal Institute of Technology SEMINAR 2-29 March Simone Stefani -

Git for Subversion users

Intro to Github. Jessica Young

Getting the files for the first time...2. Making Changes, Commiting them and Pull Requests:...5. Update your repository from the upstream master...

Lecture 3: Processing Language Data, Git/GitHub. LING 1340/2340: Data Science for Linguists Na-Rae Han

How to git with proper etiquette

1. Which of these Git client commands creates a copy of the repository and a working directory in the client s workspace. (Choose one.

G E T T I N G S TA R T E D W I T H G I T

Revision Control. How can 4. Slides #4 CMPT 276 Dr. B. Fraser. Local Topology Simplified. Git Basics. Revision Control:

Lab 08. Command Line and Git

Setting up GitHub Version Control with Qt Creator*

Git tutorial. Katie Osterried C2SM. October 22, 2015

Online Remote Repositories

Agenda. - Final Project Info. - All things Git. - Make sure to come to lab for Python next week

Submitting your Work using GIT

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

git and the virtue of version control ECE /2/2015

The Old World. Have you ever had to collaborate on a project by

Version control. with git and GitHub. Karl Broman. Biostatistics & Medical Informatics, UW Madison

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

Lecture 2: Data in Linguistics, Git/GitHub, Jupyter Notebook. LING 1340/2340: Data Science for Linguists Na-Rae Han

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

The Rock branching strategy is based on the Git Branching Model documented by Vincent Driessen.

Introduction to Git and GitHub. Tools for collaboratively managing your source code.

CS 390 Software Engineering Lecture 5 More Git

Use git rm to remove files from workspace

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

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

Version Control Systems (VCS)

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

Version Control with Git ME 461 Fall 2018

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

Using GitHub for scientific research

Version Control Systems

Tutorial 2 GitHub Tutorial

Git Introduction CS 400. February 11, 2018

b. Developing multiple versions of a software project in parallel

Version Control System - Git. zswu

git-flow Documentation

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

Distributed Version Control

API RI. Application Programming Interface Reference Implementation. Policies and Procedures Discussion

Using GitHub to Share with SparkFun a

Python Project Example Documentation

Version Control. Collaborating with git. Tim Frasier

Introduction to Git and Github

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

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

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

GIT TUTORIAL. Creative Software Architectures for Collaborative Projects CS 130 Donald J. Patterson

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

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

Django MFA Documentation

L Modeling and Simulating Social Systems with MATLAB

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 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:

Git Resolve Conflict Using Mine Command Line

I2C LCD Documentation

Software Project (Lecture 4): Git & Github

Git, the magical version control

AIS Grid School 2015

sainsmart Documentation

FEEG Applied Programming 3 - Version Control and Git II

Using GitHub and SourceTree to work with DITA TC repositories

Git AN INTRODUCTION. Introduction to Git as a version control system: concepts, main features and practical aspects.

Getting started with GitHub

Revision Control and GIT

CSC 2700: Scientific Computing

Esri on GitHub: How to Participate in Open Source Projects

Software Engineering

Version Control with GIT

Git for Version Control

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

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

Review Version Control Concepts

Code Repository. P Blanchfield

Beyond git add/commit/push

Effective Software Development and Version Control

AMath 483/583 Lecture 2

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

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

Windows. Everywhere else

History...: Displays a window of Gitk, a standard commit viewer for Git.

Version control with Git.

Table of Contents. Concepts

USER GUIDE MADCAP LINGO Source Control: Git

AMath 483/583 Lecture 2. Notes: Notes: Homework #1. Class Virtual Machine. Notes: Outline:

Object Oriented Programming. Week 1 Part 2 Git and egit

Bi 1x Spring 2014: Plotting and linear regression

Using Git to Manage Source RTL

Creating a Patch. Created by Carl Heymann on 2010 Sep 14 1

Git. Presenter: Haotao (Eric) Lai Contact:


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

Transcription:

699DR git/github Tutorial Sep 20 2017 This tutorial gives a high-level introduction into basic usage of the version control software git in combination with the online platform Github. The git commands that are covered here follow mostly the excellent introduction here: http://rogerdudler.github.io/git-guide/ If you're new to version control, watch this video: http://git-scm.com/video/what-is-version-control 1) Create an account on https://github.com/ 2) Follow these instructions to install and setup git on your computer: https:// help.github.com/articles/set-up-git/ 3) Create a new repository on Github (navigate to the Repositories tab of your profile, and click New ). These options will name the repository 699dr and initialize it:

The MIT License is standard and lets people do anything they want with your code as long as they provide attribution back to you and don t hold you liable. Click the (i) button for more information about other licenses. 4) Next, we will clone the repository from Github to our local machine. To do this, go to the repository and copy the link that shows up after clicking Clone or download. Then, in your terminal, type "git clone" followed by the link you just copied: git clone https://github.com/danxhuber/699dr.git "danxhuber" should be replaced by your Github username. The command should download the repository to your local directory. 4) Next, we will add some code to the local repository (which currently only contains the default license and readme file). We'll use a simple python script called "gaussian.py", which fits a Gaussian function to fake data in a loop. You can grab it here: http://www.ifa.hawaii.edu/~dhuber/teaching/ast699dr/gaussian.py Or copy and past the last page of this pdf to a text file and call it "gaussian.py". After copying "gaussian.py" to our local repository, add it to the repository as follows: git add gaussian.py To commit the file to your local repository, do: git commit -m "initial commit" The -m option add a comment about the commit, which is required (and detailed comments are recommended for good bookkeeping!). The final step is to push the commit to your remote repository on Github. To do this type: git push origin master The "gaussian.py" script should now show up on your Github repository. 5) Everytime you enhance the code, changes can be committed the same way. For example, after commenting out lines 38-42 from gaussian.py (which disables plotting during the loop) you could do: git commit gaussian.py -m "disabled plotting during loop"

git push origin master You can of course also do multiple commits before pushing your changes to Github. You can also make changes on Github directly (for example by editing the README.md file do add some documentation). In that case, you can sync your local copy using: git pull 6) When developing code, you ll sometimes want to implement new features independently of each other. To do this, you can generate a new branch in addition to the default master branch. For example: git checkout -b crazyfeature will create a new branch called crazyfeature, and all changes will now be committed to the crazyfeature branch. After making some changes to gaussian.py (e.g. add a print result[i] in line 38) we can do a commit and push the new branch to Github: git commit gaussian.py -m "added print statement" git push origin crazyfeature If you're happy with the implemented feature, you may want to merge the branch back into master. To do this via the commandline, first change back to the master branch: git checkout master and then merge and push to Github: git merge crazyfeature git push origin master Alternatively you can do this on Github using a "Pull Request", which will prompt you to review and approve the proposed changes in the merge (this is commonly done when contributing to someone else's code after you have forked and modified a copy). Note that merging can cause conflicts if you've made changes to multiple parts of the same code (not done in the example above). git/github will ask you to resolve these conflicts before merging. 7) At some point you may want to revert to a previous version of your code. To get a history of all the commits that have been made for a file: git log gaussian.py which in my case would show:

commit eb33abe96b90f929e2670912fe8e5ef71050873a Date: Wed Sep 20 15:20:07 2017-1000 added print statement commit c32c0090519559c3c34b01e885b933cd4c6fc4ba Date: Wed Sep 20 15:18:19 2017-1000 disabled plotting during loop commit 83ae7cb5c99dc4ae2e027dc21f6c4806dacf8fba Date: Wed Sep 20 15:17:34 2017-1000 initial commit Let's assume we regret everything we've done so far, and want to get back to the version of the initial commit (step 4). You can do this using the commit number stated in the log either by generating a new branch: git checkout -b goodoldtimes 83ae7cb5c99dc4ae2e027dc21f6c4806dacf8fba or by checking out the individual version: git checkout 83ae7cb5c99dc4ae2e027dc21f6c4806dacf8fba 8) When you've reached a stable version of the code (e.g. a version that you used for a paper), it's often useful to create a code release or "tag". From the commandline, creating a "v1.0" tag can be done as follows: git tag v1.0 eb33abe96b90f929e2670912fe8e5ef71050873a To push the tag to Github: git push origin v1.0 This should then show up as a "release" on your Github page. Releases/tagging can also be done directly on Github, and then copied to your local machine using git pull. If you've published a piece of software as part of a paper you can also make it citeable by adding a Digital Object Identifier (DOI). Instructions on how to do this can be found here: https://guides.github.com/activities/citable-code/

# simple script to fit a Gaussian to fake data from scipy.optimize import curve_fit import numpy as np import matplotlib.pyplot as plt # Gaussian function def gaussian(x, a, b, c, d): val = d + (a * np.exp(-(x - b)**2 / c**2)) return val # number of iterations nit=1000 # array to store the result of each iteration result = np.zeros(nit) # fake x-data x = np.arange(0.1,10.,0.1) plt.ion() plt.clf() for i in range(0, nit): # fake y-data y = gaussian(x,5.,5.,1.,2.)+np.random.normal(1.,0.2,x.size) # fit the data popt, pcov = curve_fit(gaussian, x, y, p0=[5.,5.,1.,3.]) # fitted model z=gaussian(x,popt[0],popt[1],popt[2],popt[3]) # save the fitted center of the gaussian result[i] = popt[1] plt.plot(x,y,'or') plt.plot(x,z) plt.draw() raw_input(':') plt.clf() # plot a histogram of fitted centers of the gaussian plt.hist(result,bins=20)