]> rtime.felk.cvut.cz Git - hubacji1/oneflow.git/blob - intro.md
Move git intro to separate file
[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 # Explore - check out the repository history
14 The command that show the whole history is `git log`. The history is build from
15 commits - changes to files in row scale.
16
17 The changes of the commit can be shown by `git show COMMIT_ID`. Where the
18 `COMMIT_ID` is the identifier obtained from `git log` command.
19
20 # Changes - check out before commit
21 The status of the repository can be checked by `git status` command. This
22 allows you to see *new files* that are not yet tracked, *changed files* whose
23 changes are not yet ready to be commited to the log history and *changed files*
24 that are ready.
25
26 The `git diff` command shows *changes* in not-yet-ready files and `git diff
27 --cached` shows *changes* that are ready to be committed.
28
29 # Commit - build repository history
30 You get ready the files to be commited to the history by `git add FILE`
31 command. If you change your mind, you may `git reset FILE` that file.
32
33 If only huks of lines in file should be prepared for commiting to the history
34 `git add -p FILE` and `git reset -p FILE` can be used respectively.
35
36 Before commiting to the history log check twice `git diff --cached` and `git
37 diff`.
38
39 When sure that staged changes should be commited to the history, use `git
40 commit -m'COMMIT MSG'`. For commit messages, some rules are good to keep in
41 mind [1][]:
42 - Separate subject from body with a blank line.
43 - Limit the subject line to 50 characters.
44 - Capitalize the subject line.
45 - Do not end the subject line with a period.
46 - Use the imperative mood in the subject line.
47 - Wrap the body at 72 characters.
48 - Use the body to explain what and why vs. how.
49
50 # Cheat sheet
51 Use `git COMMAND --help` for showing the help!
52
53 ## Init
54 - `git clone URL`
55 - `git init`
56 - `git config user.name "Your Name"`
57 - `git config user.email you@example.com`
58 - `git config --global user.name "Your Name"`
59 - `git config --global user.email you@example.com`
60
61 ## Explore
62 - `git log`
63 - `git log --graph`
64 - `git log --oneline`
65 - `git log --decorate`
66 - `git show COMMIT`
67
68 ## Changes
69 - `git diff`
70 - `git diff --cached`
71
72 ## Commit
73 - `git add FILE`
74 - `git add -p FILE`
75 - `git reset FILE`
76 - `git reset -p FILE`
77 - `git commit -m'COMMIT MSG'`
78 - `git commit`
79
80 [1]: https://chris.beams.io/posts/git-commit/