Skip to content

Commit 9dee81d

Browse files
committed
preliminary git workflow lecture
1 parent 9d51bfe commit 9dee81d

21 files changed

Lines changed: 283 additions & 148 deletions
Lines changed: 78 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title : Basic Git Commands
2+
title : Git Workflow Example
33
subtitle :
44
author : Jeffrey Leek, Assistant Professor of Biostatistics
55
job : Johns Hopkins Bloomberg School of Public Health
@@ -15,74 +15,111 @@ mode : selfcontained # {standalone, draft}
1515

1616
---
1717

18-
## So you've got a repo.... Now what?
18+
## An example workflow
1919

20-
* Once you have a repository, you'll probably make changes over time
21-
* Often, you'll want to share these changes with others (users, followers, collaborators, etc.)
22-
* __Git__ allows you to track your changes locally (on your computer)
23-
* __GitHub__ allows you to share your changes with the world (or just a few people, depending on whether your repo is public or private)
24-
* But how to communicate between Git and GitHub?
25-
* First we'll review some basic commands, then we'll look at a typical workflow
20+
* Feel free to create a test repo of your own (on your GitHub account) and follow along
21+
* This is not meant to be an exhaustive introduction to all Git and GitHub features
22+
* Best way to learn Git and GitHub are by using them
23+
* If you get stuck, use the resources at the end of the last lecture
2624

2725
---
2826

29-
## Pushing and Pulling
27+
## Create a new repo on GitHub
3028

31-
<img class=center src=../../assets/img/01_DataScientistToolbox/gghuboverview.png height='500'/>
29+
<img class=center src="../../assets/img/01_DataScientistToolbox/gitWorkflow/01createNewRepo.png" height='500'/>
3230

33-
[http://gitready.com/beginner/2009/01/21/pushing-and-pulling.html](http://gitready.com/beginner/2009/01/21/pushing-and-pulling.html)
31+
---
32+
33+
## Copy repo URL to clipboard
34+
35+
<img class=center src="../../assets/img/01_DataScientistToolbox/gitWorkflow/02copyURL.png" height='160'/>
36+
37+
---
38+
39+
## Create a new local directory
40+
41+
<img class=center src="../../assets/img/01_DataScientistToolbox/gitWorkflow/03makeDirectory.png" height='250'/>
42+
43+
---
44+
45+
## Create a new file in directory
46+
47+
<img class=center src="../../assets/img/01_DataScientistToolbox/gitWorkflow/04createFile1.png" height='100'/>
48+
<br>
49+
<br>
50+
<img class=center src="../../assets/img/01_DataScientistToolbox/gitWorkflow/05saveFile.png" height='250'/>
51+
52+
---
53+
54+
## Create a new repo locally
55+
56+
<img class=center src="../../assets/img/01_DataScientistToolbox/gitWorkflow/06newFileStatus.png" height='350'/>
57+
58+
---
59+
60+
## Add link to remote repo
61+
62+
<img class=center src="../../assets/img/01_DataScientistToolbox/gitWorkflow/09gitRemoteAdd.png" height='150'/>
3463

3564
---
3665

37-
## Adding
66+
## Stage file for commit
3867

39-
* Suppose you add some new files or make changes to a local repository (on your computer)
40-
* You need to let Git know that you want it to pay attention to these files (i.e. "track" these files)
41-
* From the directory where the repo is located on your computer (in Git Bash or Terminal, depending on whether you're on Windows or Mac, respectively):
42-
* `git add .` adds all new files (note the period after `add`, which represents "all files")
43-
* `git add -u` updates tracking for files that changed names or were deleted
44-
* `git add -A` or `git add --all` does both of the previous
68+
<img class=center src="../../assets/img/01_DataScientistToolbox/gitWorkflow/07gitAdd.png" height='350'/>
4569

4670
---
4771

48-
## Committing
72+
## Commit changes
4973

50-
* You want to organize and save "snapshots" of the files you've staged for commit
51-
* You type the command
52-
* `git commit -m "your message goes here"`, substituting a useful description (between the double quotes) of what changes you made since the last committed changes
53-
* This only updates your local repo, not the remote repo on GitHub
74+
<img class=center src="../../assets/img/01_DataScientistToolbox/gitWorkflow/08_01gitCommit.png" height='250'/>
5475

5576
---
5677

57-
## Log
78+
## Check log
5879

59-
* To see a log of the commits you've made locally, type `git log`
60-
* Spacebar advances page by page
61-
* Return advances line by line
62-
* Typing the letter "Q" exits the log
80+
<img class=center src="../../assets/img/01_DataScientistToolbox/gitWorkflow/08_02gitLog.png" height='250'/>
6381

6482
---
6583

66-
## Pushing
84+
## Push changes to GitHub
6785

68-
* Once you are pleased with your local commits, you would like to update the remote repo (on GitHub)
69-
* The command `git push` sends your most recent commits to GitHub, updating your remote repository for the world to see
86+
<img class=center src="../../assets/img/01_DataScientistToolbox/gitWorkflow/10gitPush.png" height='300'/>
7087

7188
---
7289

73-
## Pull Requests
90+
## Check status
91+
92+
<img class=center src="../../assets/img/01_DataScientistToolbox/gitWorkflow/11gitStatus.png" height='250'/>
93+
94+
---
95+
96+
## Check GitHub
97+
98+
<img class=center src="../../assets/img/01_DataScientistToolbox/gitWorkflow/12checkGitHub.png" height='300'/>
99+
100+
---
101+
102+
## Edit README file from GitHub
103+
104+
<img class=center src="../../assets/img/01_DataScientistToolbox/gitWorkflow/13editReadme.png" height='300'/>
105+
<br>
106+
<br>
107+
<img class=center src="../../assets/img/01_DataScientistToolbox/gitWorkflow/14commitNewFile.png" height='100'/>
108+
109+
---
110+
111+
## Fetch changes from GitHub
112+
113+
<img class=center src="../../assets/img/01_DataScientistToolbox/gitWorkflow/15gitFetch.png" height='300'/>
114+
115+
---
74116

75-
* If you fork someone else's repo and make some changes or additions, you may want the original author to merge your changes into their code
76-
* To do so you need to issue a pull request via GitHub
77-
* Don't need anyone's permission to fork and make changes, but the original author is not obligated to accept your changes
78-
* Pull requests offer a powerful means of contributing to open source software
117+
## Merge changes into local repo
79118

80-
<img class=center src=../../assets/img/01_DataScientistToolbox/pull_request1.png height='150'/>
119+
<img class=center src="../../assets/img/01_DataScientistToolbox/gitWorkflow/16gitMerge.png" height='350'/>
81120

82121
---
83122

84-
## Time to be a hacker!
123+
## Check status
85124

86-
* Git documentation [http://git-scm.com/doc](http://git-scm.com/doc)
87-
* Github help [https://help.github.com/](https://help.github.com/)
88-
* Google/Stack Overflow are great for Github
125+
<img class=center src="../../assets/img/01_DataScientistToolbox/gitWorkflow/17gitStatus.png" height='300'/>

0 commit comments

Comments
 (0)