Git support the concept of aliases which provides a way for users to extend Git in a lightweight fashion. Git aliases are conceptually very similar to Bash/Zsh aliases. Here we provide a list of aliases that you might find useful in your workflow.
Aliases
co
A shortcut for checkout
.
Installing
$ git config --global alias.co 'checkout'
Usage
$ git co
Example
$ git co -b bugfix Switched to a new branch 'bugfix'
ci
A shortcut for commit
.
Installing
$ git config --global alias.ci 'commit'
Usage
$ git ci
Example
$ git ci -m 'Fixed typo in README' [master a0489d9] Fixed typo in README 1 file changed, 1 insertion(+)
st
A shortcut for status --short
.
Installing
$ git config --global alias.st 'status --short'
Usage
$ git st
Example
$ git st M README.md
root
Prints the top-level directory of the current repository.
Installing
$ git config --global alias.root 'rev-parse --show-toplevel'
Usage
$ git root
Example
$ git root /home/ehelin/git/github.com/openjdk/jdk
staged
Shows a diff of the staged changes.
Installing
$ git config --global alias.staged 'diff --staged'
Usage
$ git staged
Example
$ git staged index 813fe32..4dc5c9a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ - TYPO # OpenJDK Project Skara +Welcome to project Skara! + The goal of Project Skara is to investigate alternative SCM and code review options for the OpenJDK source code, including options based upon Git rather than Mercurial, and including options hosted by third parties.
publish
Publish the local branch to the origin
remote and track it. Note: this alias conflicts with the Skara CLI tool's command publish
, do not use both!
Installing
$ git config --global alias.publish '! git push --set-upstream origin $(git branch --show-current)'
Usage
$ git publish
Example
$ git publish Enumerating objects: 27, done. Counting objects: 100% (27/27), done. Delta compression using up to 8 threads Compressing objects: 100% (9/9), done. Writing objects: 100% (14/14), 2.05 KiB | 2.05 MiB/s, done. Total 14 (delta 7), reused 0 (delta 0), pack-reused 0 remote: Resolving deltas: 100% (7/7), completed with 7 local objects. remote: remote: Create a pull request for 'https-credentials' on GitHub by visiting: remote: https://github.com/edvbld/skara/pull/new/https-credentials remote:
sync
Push all commits from the remote upstream
to the remote origin
. Note: this alias conflicts with the Skara CLI tool's command sync
, do not use both!
Installing
$ git config --global alias.sync '! git fetch upstream && git push --atomic origin $(git for-each-ref --format "%(refname):%(refname:strip=3)" refs/remotes/upstream)'
Usage
$ git sync
Example
$ git sync remote: Enumerating objects: 27, done. remote: Counting objects: 100% (27/27), done. remote: Compressing objects: 100% (2/2), done. remote: Total 14 (delta 7), reused 14 (delta 7), pack-reused 0 Unpacking objects: 100% (14/14), 2.05 KiB | 116.00 KiB/s, done. From https://github.com/openjdk/skara 0fec136..4b702e7 master -> upstream/master Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 To https://github.com/edvbld/skara.git 92cc5c5..4b702e7 upstream/master -> master
glog
Shows the commit history as a graph in a compact format.
Installing
$ git config --global alias.glog "log --color --format='format:%C(auto)%h %C(auto)%s %C(auto)%d' --graph --all --abbrev"
Usage
$ git glog
Example
$ git glog * 939a493bdd Merge (HEAD -> fibers, origin/fibers, origin/HEAD) |\ | * 6a9a93bc32 Minor improvements * | c5756b560d Merge |\| | * bcdbc8622a 8240914: java_lang_Throwable::fill_in_stack_trace should use Handler for "cont" | * 0965d252c1 8241331: Implement basic support of test execution using vthread wrapper | * f0a7aab1f6 Replace fibers by virtual threads in the test summary * | 55a94cafe9 Merge |\| | * f5a2ff5c2c JFR Thread Sleep event for virtual threads * | 15d5a97ec0 Merge |\| | * 28709d479c Merge | |\ | | * af28093ed8 Merge (origin/master, master) | | |\ | | | * 9fe762d3c5 8241162: ProblemList serviceability/sa/TestHeapDumpForInvokeDynamic.java on OSX | | * | ea367322f2 8241030: rename HtmlTag to TagName | | |/ | | * 34b9ac2287 8236285: [JVMCI] improve TranslatedException traces