Managing Projects with Git (and other command-line skills) Dr. - - PowerPoint PPT Presentation

managing projects with git
SMART_READER_LITE
LIVE PREVIEW

Managing Projects with Git (and other command-line skills) Dr. - - PowerPoint PPT Presentation

Managing Projects with Git (and other command-line skills) Dr. Chris Mayfield Department of Computer Science James Madison University Feb 18, 2020 Part 1: Group Repository What is Git/GitHub? Git is a version control system GitHub is a


slide-1
SLIDE 1

Managing Projects with Git

(and other command-line skills)

  • Dr. Chris Mayfield

Department of Computer Science James Madison University

Feb 18, 2020

slide-2
SLIDE 2

Part 1: Group Repository

slide-3
SLIDE 3

What is Git/GitHub?

Git is a version control system GitHub is a social network Tutorials:

◮ https://guides.github.com/activities/hello-world/ ◮ https://kbroman.org/github tutorial/

Cheat Sheet:

◮ https://education.github.com/git-cheat-sheet-education.pdf

Feb 18, 2020 Managing Projects with Git 3 of 14

slide-4
SLIDE 4

Setup (IMPORTANT)

git config --global user.name "firstname lastname"

◮ select a name that is identifiable for credit when reviewing

version history git config --global user.email "email address"

◮ select an email address that will be associated with each

history marker git config --global color.ui auto

◮ automatic command line coloring for Git for easy reviewing

Feb 18, 2020 Managing Projects with Git 4 of 14

slide-5
SLIDE 5

GitHub simplified

  • 1. Clone your repository (one-time setup)

◮ git clone https://github.com/cs374/teamname.git

  • 2. Make changes to the files

◮ Using your favorite editors, dev tools, etc.

  • 3. Add new files, commit changes

◮ git add newfile.txt ◮ git commit -m ”this is what I changed”

  • 4. Pull changes from team members

◮ git pull

  • 5. Push your changes to the repository

◮ git push Feb 18, 2020 Managing Projects with Git 5 of 14

slide-6
SLIDE 6

Git quick reference

Typical workflow git pull merge in the latest commits . . . make changes to your files git status what files have I changed? git diff show changes I have made git commit -m "message" save changes to repository git push upload my latest commits Other commands git add FILE add new FILE to repository git rm FILE remove FILE from repository git mv SRC DST move/rename in repository git checkout FILE undo local changes to FILE git help show a list of git commands

Feb 18, 2020 Managing Projects with Git 6 of 14

slide-7
SLIDE 7

Using meld with git

In the Linux lab, use meld . instead of git diff

Feb 18, 2020 Managing Projects with Git 7 of 14

slide-8
SLIDE 8

Part 2: Group Database

slide-9
SLIDE 9

Your group database

(My example group name is absent) To connect using psql

◮ psql -h data.cs.jmu.edu absent

Remember to change the owner

◮ CREATE TABLE person (pid integer, name text);

◮ person is owned by current user by default

◮ ALTER TABLE person OWNER TO absent;

◮ person is now owned by the entire group

GP2 will use psql to import data

psql -c "\copy person FROM person.csv WITH CSV HEADER" absent

Feb 18, 2020 Managing Projects with Git 9 of 14

slide-10
SLIDE 10

Input and output

Pipelining: program1 | program2

◮ make the output of p1 the input of p2 ◮ can be used to chain multiple processes

◮ grep 2012 movies.csv | sort | head -n 20

Redirection: program < input file > output file

◮ read a file instead of the keyboard ◮ write a file instead of the terminal

◮ psql absent < create.sql > results.txt

These operators work on Linux, Mac, and Windows!

Feb 18, 2020 Managing Projects with Git 10 of 14

slide-11
SLIDE 11

Environment variables

Instead of typing:

◮ psql -h data.cs.jmu.edu -U mayfiecs absent

Define variables:

◮ export PGHOST=data.cs.jmu.edu ◮ export PGUSER=mayfiecs ◮ export PGDATABASE=absent ◮ psql (with no arguments)

(add to ∼/.profile to make them permanent) https://www.postgresql.org/docs/11/libpq-envars.html

Feb 18, 2020 Managing Projects with Git 11 of 14

slide-12
SLIDE 12

Password file (optional)

Are you tired of typing your student number?

◮ Create a .pgpass file (and chmod 600)

data.cs.jmu.edu:5432:*:username:password https://www.postgresql.org/docs/11/libpq-pgpass.html

Feb 18, 2020 Managing Projects with Git 12 of 14

slide-13
SLIDE 13

SSH keys (optional)

Are you tired of typing your stu password?

◮ Run ssh-keygen on your machine (one-time setup) ◮ Run ssh-copy-id username@student.cs.jmu.edu

◮ Adds your public key to ∼/.ssh/authorized keys

Pick a good passphrase to protect your key (and identity)

◮ In case someone steals your laptop / private key file

Tip: Add your public key to GitHub and clone over ssh

◮ Then you’ll never need to type your GitHub password

Feb 18, 2020 Managing Projects with Git 13 of 14

slide-14
SLIDE 14

SSH config (optional)

Are you tired of typing long ssh commands? For example:

ssh -L 5432:data.cs.jmu.edu:5432 username@student.cs.jmu.edu

◮ Create a ∼/.ssh/config file with the following:

Host stu Hostname student.cs.jmu.edu User username LocalForward 5432 data.cs.jmu.edu:5432

◮ Now you can just type ssh stu (ideally with no password)

Feb 18, 2020 Managing Projects with Git 14 of 14