├── LICENSE ├── README.md ├── gitattributes └── gitconfig /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Christopher Rebert 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | gitconfig 2 | ========= 3 | 4 | git command aliases to make its interface halfway logical and user-friendly 5 | 6 | ## Command summary 7 | 8 | ### Core 9 | * `clobber ` : Clobbers part of the working copy with the original version from the current branch 10 | * `amend` : Amends the last commit to include the changes currently in staging 11 | * `amend-author 'J. Random '` : Amends the authorship information of the last commit 12 | * `stage ` : Adds the changes in the given files to the staging area from the working copy 13 | * `stage-patch ` : Interactively stage parts of changes in the given files to the staging area from the working copy 14 | * `unstage ` : Un-stages the changes in the given files from the staging area back to the working copy 15 | 16 | ### Diff-related 17 | * `diff-unstaged ` : Diffs the working copy against staging 18 | * `difftool-unstaged ` : Graphically diffs the working copy against staging 19 | * `wdiff-unstaged ` : Wordwise-diffs the working copy against staging 20 | 21 | * `diff-staged ` : Diffs staging against the last commit 22 | * `difftool-staged ` : Graphically diffs staging against the last commit 23 | * `wdiff-staged ` : Wordwise-diffs the working copy against the last commit 24 | 25 | ### Branch-related 26 | * `branches` : Lists all branches, grouped by merge status relative to the current branch 27 | * `new-branch ` : Creates a new branch off of the current commit with the given name 28 | * `push-to ` : Pushes the current branch to the given remote 29 | * `force-push-to ` : Forcibly pushes the current branch to the given remote. Also a nice *Star Wars* reference. 30 | * `delete-branch-local ` : Deletes the given branch locally 31 | * `delete-merged-branches` : Deletes local branches that have already been merged to the current branch 32 | * `delete-branch-remote ` : Deletes the given branch from the given remote server 33 | * `set-branch-head ` : Sets the HEAD pointer of the given branch to the given commit 34 | 35 | ### Merge-related 36 | * `resolve` : Opens your graphical merge/diff tool to resolve any outstanding merge conflicts 37 | 38 | ### Stash-related 39 | * `stashes` : Lists all stashes 40 | * `stash-changes` : Stashes all uncommitted changes 41 | * `unstash ` : Un-stashes the changes by applying them to the working copy and staging area 42 | * `delete-stash ` : Permanently deletes the stashed changes 43 | 44 | ### Rebase-related 45 | * `rebase-against ` : Rebases the current branch against the given branch such that your commits will now have been made against the given branch's HEAD. 46 | * `rebase-since ` : Interactively rebases the current branch, allowing you to remix (i.e. squash, reorder, remove) all commits after the given commit 47 | -------------------------------------------------------------------------------- /gitattributes: -------------------------------------------------------------------------------- 1 | # Enforce Unix newlines 2 | *.css text eol=lf 3 | *.html text eol=lf 4 | *.java text eol=lf 5 | *.scala text eol=lf 6 | *.js text eol=lf 7 | *.json text eol=lf 8 | *.md text eol=lf 9 | *.py text eol=lf 10 | *.rb text eol=lf 11 | *.txt text eol=lf 12 | *.yml text eol=lf 13 | -------------------------------------------------------------------------------- /gitconfig: -------------------------------------------------------------------------------- 1 | [user] 2 | useConfigOnly = true 3 | [diff] 4 | # Gives more sensible diffs on the command line 5 | algorithm = patience 6 | compactionHeuristic = true 7 | # Configure diffmerge (https://sourcegear.com/diffmerge/) 8 | # as diff & merge tool 9 | tool = diffmerge 10 | [difftool "diffmerge"] 11 | cmd = diffmerge $LOCAL $REMOTE 12 | [merge] 13 | tool = diffmerge 14 | [mergetool] 15 | keepBackup = false 16 | [mergetool "diffmerge"] 17 | cmd = diffmerge --merge --result=$MERGED $LOCAL $BASE $REMOTE 18 | trustExitCode = true 19 | [branch] 20 | # Rebasing is preferable to Merging 21 | autosetuprebase = always 22 | [pull] 23 | rebase = true 24 | [push] 25 | default = simple 26 | [fetch] 27 | # Auto-kill defunct remote branches 28 | prune = true 29 | [rebase] 30 | autostash = true 31 | [stash] 32 | showPatch = true 33 | [credential] 34 | # Let OS X remember our logins for us 35 | helper = osxkeychain 36 | [alias] 37 | # Just for brevity 38 | stat = status 39 | # `checkout` should just deal with commits, not individual files too 40 | clobber = checkout -- 41 | # "cached" instead of "stage" or even "index"; yeah, that's perfectly obvious. 42 | diff-staged = diff --cached 43 | difftool-staged = difftool --cached 44 | wdiff-staged = diff --word-diff --cached 45 | diff-unstaged = diff 46 | difftool-unstaged = difftool 47 | wdiff-unstaged = diff --word-diff 48 | # Operate on the current branch for convenience 49 | # I'd like to take this opportunity to say that `push branch [to] remote` would be so much more natural 50 | # than git's `push[, to] remote[, ] branch` ordering (*sigh*) 51 | # Would just be "push" except that would break compatibility 52 | push-to = "!f() { branchname=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \\(.*\\)/\\1/'`; git push \"$1\" \"$branchname\"; }; f" 53 | force-push-to = "!f() { branchname=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \\(.*\\)/\\1/'`; git push --force-with-lease \"$1\" \"$branchname\"; }; f" 54 | # branches 55 | branches = "!sh -c 'echo Unmerged: && git branch -a -v --no-merged && echo Merged: && git branch -a -v --merged'" 56 | # `checkout` really shouldn't be the command for this 57 | new-branch = checkout -b 58 | delete-branch-local = branch -d 59 | delete-merged-branches = "!f() { git branch --no-color --merged | grep -v '\\*' | grep -v master | grep -v develop | xargs -n 1 git branch -d -D; }; f" 60 | set-branch-head = branch -f 61 | delete-branch-remote = "!f() { git push --delete \"$2\" \"$1\" ; }; f" 62 | # Make conflict resolution feel more integrated 63 | resolve = mergetool 64 | # staging 65 | stage = add --all 66 | stage-patch = add --all -p 67 | unstage = reset HEAD 68 | # stash 69 | # would just be "stash" except that would break compatibility 70 | stash-changes = stash save 71 | unstash = stash pop --index 72 | stashes = stash list 73 | delete-stash = stash drop 74 | # rebase-ish 75 | # Make amending first-class 76 | amend = commit --amend 77 | amend-author = commit --amend -C HEAD --author 78 | # Separate the two rather different uses of rebase 79 | rebase-against = rebase 80 | rebase-since = rebase -i 81 | # useful as something to diff against 82 | null-sha = hash-object -t tree /dev/null 83 | --------------------------------------------------------------------------------