forked from LRiceBall/Trending-Music-Attributes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGit Cheatsheet
75 lines (53 loc) · 1.75 KB
/
Git Cheatsheet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Clone an existing repo.
git clone <repo_url>
# Navigate into newly created repo directory
cd <repo_name>
######################################
# ADD FILES
######################################
# Create a file, called clean_data.py
touch clean_data.py
# Add and commit clean_data.py...
git add clean_data.py
git status
git commit -m "First commit."
# Add cleanup code to clean_data.py...
git add clean_data.py
git status
git commit -m "Clean up provided data."
# Add code to export clean data...Note that `add .` adds
# everything in the current folder
git add .
git status
git commit -m "Export clean data as CSV."
######################################
# Branching
######################################
#To create a new, isolated development history, we must create branches.
# Create new branch and switch to it
# Long form: `git checkout --branch data_analytics`
git checkout -b data_analytics
#Alternatively, we can create a branch and then switch to it as two separate steps, though this is uncommon.
git branch new_branch_name
git checkout new_branch_name
Once we’ve created a new branch, we can develop as normal:
# Create file to contain data analysis
git add analysis.ipynb
git status
git commit -m "Add Jupyter Notebook for data analysis."
# Add notebook cells summarizing data
git add analysis.ipynb
git status
git commit -m "Add summary tables to Jupyter Notebook."
# Export analyzed data and/or plots
git add .
git commit -m "Export analysis results and save plots as PNG files."
######################################
# MERGING
######################################
# Move back to master
git checkout master
# Merge changes on data_analysis with code on master
git merge data_analysis
# Delete the data_analysis branch
git branch -d data_analysis