forked from andrew-norman/reflections
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotes
86 lines (62 loc) · 1.9 KB
/
notes
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
76
77
78
79
80
81
82
83
84
85
86
git init
initialise repository
git log
list commits
--stat to show stats
--graph to show graph
--oneline to reduce output
git log <branch1> <branch2>
compare
git diff <id1> <id2>
changes between commits
no arguments - shows differences between working directory and staging area
--staged (with no arguments) - shows differences between staging area and
repository
git clone <url>
download repository
git config --global color.ui.auto
coloured output
git config --global core.editor mvim -f
default editor (-f to make vim wait)
git checkout <id>
restore to previous commit
git status
shows status of repository
git add <files>
add files to staging area
git commit
saves staging area to repository
git reset --hard
restores from repository (i.e. wipes any changes in working directory
or staging area since last commit).
Branching
---------
git branch
show current branches
git branch <name>
create new branch (doesn't switch to that branch!)
git checkout <name>
switch to branch (local or remote)
git checkout -b <name>
creates new branch and switches to it.
git log will track back to parents of current branch(es).
Merging
-------
git merge master <branch>
merges <branch> and master into whatever the current branch is:
1. check out master
2. git merge master <branch>
3. master now contains changes in <branch>
4. conflicts will be flagged
GitHub
------
git config --global credential.helper osxkeychain
keychain to prevent constant prompts for password
New repository - go to website, add empty repository
git remote
list remote repositories
git remote add <name> <url>
add remote repository - "origin" is standard name for first
-v to show full details for fetch and push (usually the same)
git push <remote> <branch>
pushes branch to remote (e.g. git push origin master)