2 Source Code Management (SCM) and it's great. Check out https://git-scm.com/ for
5 # Init - do it once per repository
6 You may clone it like `git clone URL` or create one from a folder by `git
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.
13 ## Command `git clone`
14 Copy existing repository that is available online from some server to local
17 git clone ssh://git@rtime.felk.cvut.cz/hubacji1/oneflow.git
21 Initialize directory to be able to use git commands.
26 ## Command `git config`
27 Setting up your name and email address is required at minimal.
29 git config user.name "Your Name"
30 git config user.email you@example.com
33 If the name and email should persist as default for any other git repository:
35 git config --global user.name "Your Name"
36 git config --global user.email you@example.com
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.
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.
47 Show the commited history changes in descending order.
52 There is some useful parameters that may be combined:
60 Use the change stored in history.
65 # What is repository current state
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*
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.
74 ## Command `git status`
75 Show information about files in repository.
80 There are 3 states for file changes (let's call them *patches*) before stored
81 to git history: *untracked*, *unstaged*, and *staged*. Note that the whole file
82 may be patch. Also, `git status` command does not show patches, but files
83 containing these patches.
85 *Untracked* means that patch was not stored by git yet.
87 *Unstaged* files has older version stored in git history but patches are not
88 ready to be stored in git history.
90 *Staged* files has older version stored in git and patches will be stored to
91 git history as soon as `git commit` command is used.
94 The patches (file changes) may be shown by `git diff` command (because `git
95 status` show files not patches).
97 Unstaged patches can be seen by:
102 And staged patches by:
107 # Commit - build repository history
108 You get ready the files to be commited to the history by `git add FILE`
109 command. If you change your mind, you may `git reset FILE` that file.
111 If only huks of lines in file should be prepared for commiting to the history
112 `git add -p FILE` and `git reset -p FILE` can be used respectively.
114 Before commiting to the history log check twice `git diff --cached` and `git
117 When sure that staged changes should be commited to the history, use `git
118 commit -m'COMMIT MSG'`. For commit messages, some rules are good to keep in
120 - Separate subject from body with a blank line.
121 - Limit the subject line to 50 characters.
122 - Capitalize the subject line.
123 - Do not end the subject line with a period.
124 - Use the imperative mood in the subject line.
125 - Wrap the body at 72 characters.
126 - Use the body to explain what and why vs. how.
129 Use `git COMMAND --help` for showing the help!
134 - `git config user.name "Your Name"`
135 - `git config user.email you@example.com`
136 - `git config --global user.name "Your Name"`
137 - `git config --global user.email you@example.com`
142 - `git log --oneline`
143 - `git log --decorate`
149 - `git diff --cached`
155 - `git reset -p FILE`
156 - `git commit -m'COMMIT MSG'`
159 [1]: https://chris.beams.io/posts/git-commit/