Questions tagged [git-alias]

With aliases, you can avoid typing the same commands over and over again. Aliases were added in Git version 1.4.0.

To show how to use Git aliases, suppose you wish you could write git ci instead of git commit. You can achieve this by adding the following section to ~/.gitconfig:

[alias] ci = commit

Some people are uncomfortable editing the config file themselves. They can edit the config by calling git config alias.ci commit instead.

If you want to have the alias available everywhere on your local machine, you can either - edit ~/.gitconfig, or - use the --global flag:

git config --global alias.ci commit

Read the Git SCM Wiki for technical details.

116 questions
6
votes
1 answer

Get the path where git alias was run from

When an external command is run via Git alias, it is run from the rood directory of the repository (where the .git/ is usually located). It can be checked with: $ cd /some/path/inside/repo $ echo $(git -c alias.root='!pwd' root) Now, is there a way…
Nick Volynkin
  • 14,023
  • 6
  • 43
  • 67
6
votes
1 answer

git alias to pull --rebase current branch

I am working on a branch called foo and I want to rebase my branch against origin/foo. In modern versions of git I could run $ git pull --rebase origin foo That's a lot of typing for a common operation. Additionally, because I have an old version…
Barry
  • 286,269
  • 29
  • 621
  • 977
5
votes
1 answer

How to share Git aliases across multiple workstations?

When using Git on multiple workstations, and for different Git repositories, it is convenient to have the same set of aliases available. So, to synchronize the Git aliases across different workstations, and across different repositories, I consider…
EquipDev
  • 5,573
  • 10
  • 37
  • 63
5
votes
1 answer

How to get file's relative path in git aliases with parameters?

I have the following aliases in my .gitconfig: [alias] lg = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold…
Patryk
  • 22,602
  • 44
  • 128
  • 244
5
votes
1 answer

Git: Alias error: Use '--' to separate paths from revisions

I created a git command that shows me the diff between the HEAD and the last Git-SVN commit. Git is the command git diff `git log --grep git-svn-id | grep commit | sed "s/commit //g" | head -1` HEAD And I wanted to make an alias for it and I did it…
Jacob Krieg
  • 2,834
  • 15
  • 68
  • 140
4
votes
1 answer

Import aliases when cloning repository

I have a repository with a repo/.git/config file where aliases are defined. Is there a handy way to import those aliases in the repo-clone/.git/config file generated by the git clone repo repo-clone command ? The two repositories are on different…
4
votes
1 answer

Git alias output coloring in function

I'm tring to add a complex git alias that will echo messages as it performs commands. I'd like to colorize some of the messages (Red for error, etc). [alias] test = !"f() { echo "\033[31mHello\033[0m World"; }; f" However when I execute the…
Jared Knipp
  • 5,880
  • 7
  • 44
  • 52
4
votes
4 answers

git alias: multiple commands, variadic parameters

I often find myself typing this: git push remote1 branch1 branch2 tag1 tag2 tag3.. git push remote2 branch1 branch2 tag1 tag2 tag3.. I would prefer an alias where I can type this instead: git pushall branch1 branch2 tag1 tag2 tag3 .. Note: I am…
donquixote
  • 4,877
  • 3
  • 31
  • 54
4
votes
2 answers

Using variables in git alias

I'm trying to create an alias for checking out the master branch and merging the branch I was on before switching. Right now, my alias looks like this: med = "!f() { git checkout master; git merge ${1}; git branch -d ${1}; }; f" It means that every…
ulu
  • 5,872
  • 4
  • 42
  • 51
4
votes
1 answer

Git config file local variables

I have a set of aliases for different type of logs, like: lg = log --graph --pretty=format:'%C(cyan)%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(red)<%an>%Creset' --abbrev-commit --date=relative unreleased = !git --no-pager log --graph…
SystematicFrank
  • 16,555
  • 7
  • 56
  • 102
3
votes
1 answer

How to alias git checkout -b with a string format for the branch name

My team uses a format for our branch names for uniformity. For a given branch, the format would be: "feature/TeamName-CardNumber". The card number is the only part of this that will change, so I would like to make an alias such as: git cobf…
3
votes
1 answer

Set up git alias with an input argument

Git aliases can be removed with git config --global --unset alias.. I want to make life easier and be able to delete git aliases with: git rmalias . My attempt for this alias is: git config --global alias.rmalias '!git config…
Casper Dijkstra
  • 1,615
  • 10
  • 37
3
votes
1 answer

Set up a quicker alias for `git push -u origin $BRANCH_NAME` and `git push` at the same time

When I want to push changes on a branch that already has upstream branch, git push is all I need. But when there's no current upstream branch, I have to type out git push -u $BRANCH_NAME. I create new branches all the time (for every feature that I…
Max Yankov
  • 12,551
  • 12
  • 67
  • 135
3
votes
1 answer

Can't add git alias when using shell function

I'm trying to add the following alias using shell function scommit = "!f() { git submodule foreach -q --recursive 'git commit -a || :' ; git commit -am \" Update submodule \";}; f" But when I run it in Git bash (on Windows) git config --local…
Pr.Dumbledor
  • 636
  • 1
  • 11
  • 29
3
votes
1 answer

Adding git alias with pipes complains about wrong configuration

I am trying to add a git alias that makes me abort a rebase that have just finished. I tried to add this in .gitconfig: rebabort = !sh -c 'git reflog | grep -v rebase | head -1 | sed -e "s/^\([[:alnum:]][[:alnum:]]*\)\(.*\)/\1/g" | git reset…
se7entyse7en
  • 4,310
  • 7
  • 33
  • 50