]> rtime.felk.cvut.cz Git - hubacji1/oneflow.git/blobdiff - intro.md
Move git intro to separate file
[hubacji1/oneflow.git] / intro.md
diff --git a/intro.md b/intro.md
new file mode 100644 (file)
index 0000000..d3ab15e
--- /dev/null
+++ b/intro.md
@@ -0,0 +1,80 @@
+# Git is ...
+Source Code Management (SCM) and it's great. Check out https://git-scm.com/ for
+details.
+
+# Init - do it once per repository
+You may clone it like `git clone URL` or create one from a folder by `git
+init`.
+
+Also, just after first commit, you may be asked to set up your name and email
+address with `git config ...` command. If `--global` is used the name and/or
+email will be automatically used for all the commits.
+
+# Explore - check out the repository history
+The command that show the whole history is `git log`. The history is build from
+commits - changes to files in row scale.
+
+The changes of the commit can be shown by `git show COMMIT_ID`. Where the
+`COMMIT_ID` is the identifier obtained from `git log` command.
+
+# Changes - check out before commit
+The status of the repository can be checked by `git status` command. This
+allows you to see *new files* that are not yet tracked, *changed files* whose
+changes are not yet ready to be commited to the log history and *changed files*
+that are ready.
+
+The `git diff` command shows *changes* in not-yet-ready files and `git diff
+--cached` shows *changes* that are ready to be committed.
+
+# Commit - build repository history
+You get ready the files to be commited to the history by `git add FILE`
+command. If you change your mind, you may `git reset FILE` that file.
+
+If only huks of lines in file should be prepared for commiting to the history
+`git add -p FILE` and `git reset -p FILE` can be used respectively.
+
+Before commiting to the history log check twice `git diff --cached` and `git
+diff`.
+
+When sure that staged changes should be commited to the history, use `git
+commit -m'COMMIT MSG'`. For commit messages, some rules are good to keep in
+mind [1][]:
+- Separate subject from body with a blank line.
+- Limit the subject line to 50 characters.
+- Capitalize the subject line.
+- Do not end the subject line with a period.
+- Use the imperative mood in the subject line.
+- Wrap the body at 72 characters.
+- Use the body to explain what and why vs. how.
+
+# Cheat sheet
+Use `git COMMAND --help` for showing the help!
+
+## Init
+- `git clone URL`
+- `git init`
+- `git config user.name "Your Name"`
+- `git config user.email you@example.com`
+- `git config --global user.name "Your Name"`
+- `git config --global user.email you@example.com`
+
+## Explore
+- `git log`
+- `git log --graph`
+- `git log --oneline`
+- `git log --decorate`
+- `git show COMMIT`
+
+## Changes
+- `git diff`
+- `git diff --cached`
+
+## Commit
+- `git add FILE`
+- `git add -p FILE`
+- `git reset FILE`
+- `git reset -p FILE`
+- `git commit -m'COMMIT MSG'`
+- `git commit`
+
+[1]: https://chris.beams.io/posts/git-commit/