-
Notifications
You must be signed in to change notification settings - Fork 1
/
git.py
67 lines (47 loc) · 1.73 KB
/
git.py
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
#GIT CHEATSHEET
#Setup
git config --global user.name #set a name that is identifiable for credit when review version history
git config --global user.email #set an email address that will be associated with each history marker
git config --global color.ui auto #set automatic command line coloring for git for easy reviewing
#Initializes a new local repository with git
git init #works in an existing repository
#Add files to the staging area
git add {file_name} #use this command to add a single file to the staging area
###or###
git add . #use this command to add all files to the staging area
#Check the state of the staging area
git status
#View the entire commit story
git log
#Commit files on your local repository
git commit #commit all files
###or###
git commit -m "message" #commit an individual file
#Download existing code from a remote repository
git clone {url}
#List all the local branches on the machine
git branch
#merge the provided branch with the current working branch
git merge {branch_name}
#Create a new branch locally
git branch {branch_name}
#Delete a branch
git branch -d {branch_name}
#Rename the current working branch
git branch -m {branch_new_name}
#Swicth from the current branch to another one
git checkout {branch_name}
#Save all commits to a remote repository
git push {url} {branch_name}
#Create a new branch and swicth to it
git checkout -b {branch_name}
#Pull down all the updates from a remote repository
git pull {url}
#Remove a file from the local directory
git rm {file_name}
#Remove uncommited chances temporarily
git stash
#Chance to the local files and restore to the last commit
git reset
#Display the difference between files in two commits or between a commit and your current repository
git diff