|
@@ -1,7 +1,7 @@
|
|
|
# Git Book
|
|
|
[Git Book](https://git-scm.com/book/en/v2)
|
|
|
|
|
|
-## Chapter 1
|
|
|
+## Chapter 1: Getting Started
|
|
|
* Git tracks snapshots, not differences (virtual filesystem)
|
|
|
* Nearly every operation is local
|
|
|
* Has integrity included
|
|
@@ -31,7 +31,7 @@ $ git config --list
|
|
|
* git 'verb' --help
|
|
|
* man git-'verb'
|
|
|
|
|
|
-## Chapter 2
|
|
|
+## Chapter 2: Git Basics
|
|
|
|
|
|
### Getting a Repository
|
|
|
* New repositor: `$ git init`
|
|
@@ -118,12 +118,73 @@ $ git config --list
|
|
|
```
|
|
|
* Show graph: `git log --pretty=format:"%h %s" --graph`
|
|
|
* other options:
|
|
|
- - -(n) show only the last n commits
|
|
|
- - --since, --after Limit to commits after a date
|
|
|
- - --until, --before Limit to commits before a date
|
|
|
- - --author Filter by author
|
|
|
- - --committer Filter by committer
|
|
|
- - --grep Filter by content of the commit string
|
|
|
- - -S Only show commits adding or removing code matching the string
|
|
|
+ - `-(n)` show only the last n commits
|
|
|
+ - `--since`, `--after` Limit to commits after a date
|
|
|
+ - `--until`, `--before` Limit to commits before a date
|
|
|
+ - `--author` Filter by author
|
|
|
+ - `--committer` Filter by committer
|
|
|
+ - `--grep` Filter by content of the commit string
|
|
|
+ - `-S` Only show commits adding or removing code matching the string
|
|
|
+
|
|
|
+### Undoing things
|
|
|
+* You forgot to stage some files. Use `$ git commit --amend` to commit remaining files. Works only, if no changes were made since last commit.
|
|
|
+* Unstage a staged file: `$ git reset HEAD <file>`
|
|
|
+* Unmodify a modify file: `'git checkout -- <file>`. Consider branching or stashing instead.
|
|
|
+
|
|
|
+### Working with remotes
|
|
|
+* Showing repositories: `$ git remote -v`
|
|
|
+* Adding remotes: `$ git remote add <handle> <url>`
|
|
|
+* Fetching from remotes (receive data you don't have yet): `$ git fetch <handle>`
|
|
|
+* Pulling from remotes (fetching and merging): `$ git pull <handle>`
|
|
|
+* Fetching and pulling by default works on tracked remote branches.
|
|
|
+* Pushing to remotes: `$ git push origin master`
|
|
|
+* Show information about a remote: `$ git remote show origin`
|
|
|
+ - Fetch URL
|
|
|
+ - Push URL
|
|
|
+ - HEAD branch
|
|
|
+ - Remote branches
|
|
|
+ - Local branch configured for 'git pull'
|
|
|
+ - Local ref configured for 'git push'
|
|
|
+* Renaming remotes: `$ git remote rename pb paul`
|
|
|
+* Removing remotes: `$ git remote remove paul`
|
|
|
+
|
|
|
+### Working with tags
|
|
|
+* listing tags: `$ git tag`
|
|
|
+* listing tags of a series: `$ git tag -l "v1.8.5*"`
|
|
|
+* There are two types of tags:
|
|
|
+ - lightweight
|
|
|
+ - annotated
|
|
|
+* A lightweight tag is like a branch that doesn't change.
|
|
|
+* An annotated tag is checksummed, contains tagger name, email and date. They have a tagging message and can be signed with GPG.
|
|
|
+* `-m` specifies the tag message.
|
|
|
+* creating an annotated tag: `$ git tag -a v1.4 -m "my version 1.4"`
|
|
|
+* creating a lightweight tag: `$ git tag v1.4-lw`
|
|
|
+* show information about a tag: `$ git show v1.4`
|
|
|
+* You can tag after other commits have been made:
|
|
|
+ ```
|
|
|
+ $ git log --pretty=oneline
|
|
|
+ 15027957951b64cf874c3557a0f3547bd83b3ff6 Merge branch 'experiment'
|
|
|
+ a6b4c97498bd301d84096da251c98a07c7723e65 beginning write support
|
|
|
+ 0d52aaab4479697da7686c15f77a3d64d9165190 one more thing
|
|
|
|
|
|
+ $ git tag -a v1.2 a6b4c9
|
|
|
+ ```
|
|
|
+* sharing tags with remotes: `$ git push origin v1.5`
|
|
|
+* to push all tags at once: `$ git push origin --tags`
|
|
|
+* You can't check out tags in git. You must checkout a branch at a specific tag:
|
|
|
+ - `$ git checkout -b version2 v2.0.0`
|
|
|
+
|
|
|
+### Aliases
|
|
|
+* Can be done with `$ git config --global alias.co checkout`
|
|
|
+* or in the .gitconfig file
|
|
|
+* usefull aliases:
|
|
|
+ - co checkout
|
|
|
+ - br branch
|
|
|
+ - ci commit
|
|
|
+ - st status
|
|
|
+ - unstage reset HEAD --
|
|
|
+ - last log -1 HEAD
|
|
|
+ - visual !gitk
|
|
|
+
|
|
|
+## Chapter 3: Git Branches
|
|
|
|