-
Notifications
You must be signed in to change notification settings - Fork 3
/
GitNotes.txt
90 lines (64 loc) · 3.34 KB
/
GitNotes.txt
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
87
88
89
90
Git notes
Tutorial with Dan -- 7-Jan-2012
Create a new repository:
in the directory with the file(s) you want to commit,
git init
Adding a file to the "staging area":
git add GitNotes.txt
To commit staging area to a "commit object":
git commit -m "commit msg"
To get status (to show what is in staging area -- i.e., what will be committed when type 'commit', and untracked changes):
git status
Look at commit:
git log -p
(the 'p' shows the changes between current to previous commits)
to stage and commit in one command:
git commit -am "this will stage and commit in one cmd"
to see differences between working directory and most recent commit (or staging, if it exists):
git diff shows lines that are different (red: removed green: added)
or
git diff --color-words shows only words that are different (red: removed green: added)
(need to type 'q' to get out of pager for "diff" and "log" and other commands that use the pager)
We just checked out branch 75d94622e2d2c4, and create a new branch called "retrospection":
git checkout 75d94622e2d2c4
git branch retrospection
We go into the new branch:
git checkout retrospection
can do all 3 above commands in a single command:
git checkout 75d94622e2d2c4 -b retrospection
check out "master" branch (to get ready to merge with "retrospection" branch):
git checkout master
merge "retrospection" branch into "master" branch
git merge retrospection
this caused a merge conflict -- I had to remove the tags that git put into the resultant file.
then commit the result (to get the merged file into the master branch):
git commit -am "resolve merge conflict between retrospection into master"
to see all the commits:
git log
to get a clone of an entire git repository:
git clone <path/name> (can be local, or SSH, or http, or whatever)
Dan did a git clone of his rgb firmware on his USB drive, in a directory called "rgbled"
I changed directory to: C:\Projects\RGBwaves Kit\firmware\Dan\DanGit
and then, to get a clone of that on my computer:
git clone d:\rgbled
Can fetch commit objects from a branch of a remote repository:
git fetch <path/name>
This does not merge with your local branch, which creates a new branch called "remotes"
To merge, can do a normal merge (to merge into your local branch, such as the master branch)
git checkout master
Alternatively to the above, can do a "pull" to fetch and merge (if possible) in one command:
git pull <path/name>
(if the merge has conflicts, it will only do a fetch)
"push" works similar to "pull" (but will not destroy content in the working directory -- it will not do anything if it will destroy data).
Can create a "bare" repository on a remote (or local) server, which acts as a central respository.
A bare repository has no working directory.
As an example of using "push", I created "tempdir", to emulate a remote server, then cloned the git repository there.
then reset it to get rid of some commits.
Then use the "push" command:
git push tempdir master:master
Create a github account, and then put this tutorial there.
git push
to see a graphical representation (in all text), with colors, showing branch names and commit IDs:
git log --graph --decorate --pretty=oneline --all
to see a list of files that are committed:
git ls-files