Git
Git vs Svn
| git | svn |
|---|---|
| push | commit |
| master | trunk |
| pull | update |
Links
- Inspecting a repository 1, Git lets you completely ignore files by placing paths in a special file called
.gitignore. - Saving changes 2, add, commit, stash.
- Sync 3 with fetch, remote, push, pull
Git Command Line
- The common Git guides are:
| guide | description |
|---|---|
| attributes | Defining attributes per path |
| everyday | Everyday Git With 20 Commands Or So |
| glossary | A Git glossary |
| ignore | Specifies intentionally untracked files to ignore |
| modules | Defining submodule properties |
| revisions | Specifying revisions and ranges for Git |
| tutorial | A tutorial introduction to Git (for version 1.5.1 or newer) |
| workflows | An overview of recommended workflows with Git |
Run like git help <guide_name>.
- Git Bash
git log -10
git diff HEAD
git add tools/git.md
git status
# commit everything with message and author overridden
git commit -a -m 'modified git.md' --author illegitimis
git help push
git push
git push origin
git reset HEAD^
git revert <commit>
# list local and remote branches verbose
git branch --list -a -vv
- update fork. If using SourceTree one can pull from remote origin, selecting the dev branch to pull.
cd <dir_where_i_cloned_my_fork_of_a_repo>
git remote add bradyholt-cron-expression-descriptor-master https://github.com/bradyholt/cron-expression-descriptor
git pull bradyholt-cron-expression-descriptor-master master
# unstage_conflicts
- git push SSL_ERROR_SYSCALL
git config http.postBuffer 524288000
- file history
- GitLens 4 extension
-
file commit history with patches and beyond renames
rem path to file is relative to root rem differentiates revisions from files $ git log --follow -p -- ./src/Proj/Validation/OrderRequestDtoValidator.cs
- stashes
git stash list
git stash show stash@{0}
- github update fork from master
git remote -v
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
git remote -v
git fetch upstream
git checkout master
git merge upstream/master
git push -v --tags origin master:master
Configuration
git config --global core.autocrlf true # Windows
git config --global core.autocrlf input # Linux
git config --global --edit
.gitattributes line endings:
* text=auto
* text eol=crlf
* text eol=lf
Merge
git fetch origin
git merge origin/develop
git log develop..HEAD --oneline --no-merges
git rm --cached <file>
File History
# Basic history
git log -- path/to/file.txt
# One-line summary per commit
git log --oneline -- path/to/file.txt
# With diffs (what changed in each commit)
git log -p -- path/to/file.txt
# Last N commits
git log -5 -- path/to/file.txt
# Follow renames
git log --follow -- path/to/file.txt