]> rtime.felk.cvut.cz Git - hubacji1/oneflow.git/blob - intro.md
Expand explore section in introduction
[hubacji1/oneflow.git] / intro.md
1 # Git is ...
2 Source Code Management (SCM) and it's great. Check out https://git-scm.com/ for
3 details.
4
5 # Init - do it once per repository
6 You may clone it like `git clone URL` or create one from a folder by `git
7 init`.
8
9 Also, just after first commit, you may be asked to set up your name and email
10 address with `git config ...` command. If `--global` is used the name and/or
11 email will be automatically used for all the commits.
12
13 ## Command `git clone`
14 Copy existing repository that is available online from some server to local
15 directory.
16 ```
17 git clone ssh://git@rtime.felk.cvut.cz/hubacji1/oneflow.git
18 ```
19
20 ## Command `git init`
21 Initialize directory to be able to use git commands.
22 ```
23 git init
24 ```
25
26 ## Command `git config`
27 Setting up your name and email address is required at minimal.
28 ```
29 git config user.name "Your Name"
30 git config user.email you@example.com
31 ```
32
33 If the name and email should persist as default for any other git repository:
34 ```
35 git config --global user.name "Your Name"
36 git config --global user.email you@example.com
37 ```
38
39 # Explore the repository history
40 The command that show the whole history is `git log`. The history is build from
41 commits - changes to files in row scale.
42
43 The changes of the commit can be shown by `git show COMMIT_ID`. Where the
44 `COMMIT_ID` is the identifier obtained from `git log` command.
45
46 ## Command `git log`
47 Show the commited history changes in descending order.
48 ```
49 git log
50 ```
51
52 There is some useful parameters that may be combined:
53 ```
54 git log --graph
55 git log --oneline
56 git log --decorate
57 ```
58
59 ## Command `git show`
60 Use the change stored in history.
61 ```
62 git show COMMIT_ID
63 ```
64
65 # Changes - check out before commit
66 The status of the repository can be checked by `git status` command. This
67 allows you to see *new files* that are not yet tracked, *changed files* whose
68 changes are not yet ready to be commited to the log history and *changed files*
69 that are ready.
70
71 The `git diff` command shows *changes* in not-yet-ready files and `git diff
72 --cached` shows *changes* that are ready to be committed.
73
74 # Commit - build repository history
75 You get ready the files to be commited to the history by `git add FILE`
76 command. If you change your mind, you may `git reset FILE` that file.
77
78 If only huks of lines in file should be prepared for commiting to the history
79 `git add -p FILE` and `git reset -p FILE` can be used respectively.
80
81 Before commiting to the history log check twice `git diff --cached` and `git
82 diff`.
83
84 When sure that staged changes should be commited to the history, use `git
85 commit -m'COMMIT MSG'`. For commit messages, some rules are good to keep in
86 mind [1][]:
87 - Separate subject from body with a blank line.
88 - Limit the subject line to 50 characters.
89 - Capitalize the subject line.
90 - Do not end the subject line with a period.
91 - Use the imperative mood in the subject line.
92 - Wrap the body at 72 characters.
93 - Use the body to explain what and why vs. how.
94
95 # Cheat sheet
96 Use `git COMMAND --help` for showing the help!
97
98 ## Init
99 - `git clone URL`
100 - `git init`
101 - `git config user.name "Your Name"`
102 - `git config user.email you@example.com`
103 - `git config --global user.name "Your Name"`
104 - `git config --global user.email you@example.com`
105
106 ## Explore
107 - `git log`
108 - `git log --graph`
109 - `git log --oneline`
110 - `git log --decorate`
111 - `git show COMMIT`
112
113 ## Changes
114 - `git diff`
115 - `git diff --cached`
116
117 ## Commit
118 - `git add FILE`
119 - `git add -p FILE`
120 - `git reset FILE`
121 - `git reset -p FILE`
122 - `git commit -m'COMMIT MSG'`
123 - `git commit`
124
125 [1]: https://chris.beams.io/posts/git-commit/