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
3
votes
1 answer

Git alias to add prefix to name of new branch

Is there a way to write an alias that adds current date to name of new branch? For example: git branch-today new_branch_name should create new branch with 22_09_2015_new_branch_name name.
Andrii Iushchuk
  • 376
  • 1
  • 9
3
votes
1 answer

Bad variable name in Bash from a Git alias

I have the following Git alias in my global git config. pushnew = !f() { export tmp_branch=`git branch | grep '* ' | tr -d '* '` && git push --set-upstream origin $tmp_branch; unset $tmp_branch; }; f When running it I get the following output: *…
bcmcfc
  • 25,966
  • 29
  • 109
  • 181
3
votes
1 answer

Simplify Xargs expression in git alias

I'm trying to make a git alias to approve pull request(s) on GitHub. The main feature of this alias is ability to octopus merge multiple pull requests. What I got so far (.gitconfig): [alias] approve = "!f() { git fetch origin $(echo $@ | xargs…
hazzik
  • 13,019
  • 9
  • 47
  • 86
3
votes
1 answer

Is there a robust way of checking whether a prospective Git alias name is available?

Git allows you to create your own custom Git verbs, or aliases, using git config [--global] alias. "" If you're not very familiar with Git commands, though, you may choose an alias name that corresponds to an existing…
jub0bs
  • 60,866
  • 25
  • 183
  • 186
3
votes
1 answer

git alias for starting gitk and git gui in the background

Well I have tried countless variations of : git config --global alias.gg '!gitk --all &; git gui &' but they do not work or just display only gitk like this one : [alias] gg = !gitk --all& ; git gui&
Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361
3
votes
1 answer

GitConfig: bad config for shell command

I'm trying to set up an alias, as I have many. For some reason, this one does not work. Any idea? [alias] t = "!git log --decorate --oneline | egrep '^[0-9a-f]+ \(tag: ' | sed -r 's/^.+tag: ([^ ]+)[,\)].+$/\1/g'" Command works fine by itself: $ git…
shkschneider
  • 17,833
  • 13
  • 59
  • 112
2
votes
1 answer

How to make bash as default shell in git alias?

Is there a way to specify the default shell used by git alias (which is currently /bin/sh for linux systems and /bin/zsh for macOS)? I know that we can wrap the command with bash -c '' but I was looking for a way to change the…
2
votes
3 answers

Git alias to squash feature-branch commits

I'm frequently squashing all the commits on a feature branch before committing to master. Here's what I do currently: git checkout master git merge --squash {branch} git commit -m "{feature_summary}" Is there an git alias I can use to do this? The…
Maximilian
  • 7,512
  • 3
  • 50
  • 63
2
votes
2 answers

Git commit --amend alias hangs

I have this alias in my ~/.gitconfig: [alias] am = commit -a --amend -C HEAD Yet, when I run git am, it hangs, and I get (master|AM/REBASE) at the prompt, and I have to run git am --abort.
Geremia
  • 4,745
  • 37
  • 43
2
votes
1 answer

Git alias with multiple command

After a review, i need to change some code and repush all my change code on the remote branch. So i would like to automate on git with an alias (ex: git repushall) these different commands: git add . git commit --amend (and ctrl + x) git push…
Tim
  • 162
  • 2
  • 10
2
votes
1 answer

How to pass parameters from a git alias to an external script

I am having a problem passing parameters to an external bash script file from git aliases. Currently, I have my bash script file in the same directory as my .gitconfig. I plan on moving all my complex !f() { } aliases in there to avoid battling…
Terry
  • 2,148
  • 2
  • 32
  • 53
2
votes
1 answer

How to properly use parameters in git aliases?

I have the following git alias in my .gitconfig file. clone-with-branches = "!cloneWithBranches() { \ git clone $1 $2 ; \ }; cloneWithBranches" I am supposed to use it as follows: git clone-with-branches folder1 folder2 (supposing…
Pat. ANDRIA
  • 2,330
  • 1
  • 13
  • 27
2
votes
1 answer

Passing string in positional parameter for Git alias

I am trying to create a git alias that takes a string as a entire positional paramter. For e.g. I have a alias as follows: my-alias = "!f() { \ param1 = $1; \ param2 = $2; \ rem_param = ${@:3};\ };f" And I want to use alias…
patronus
  • 103
  • 1
  • 7
2
votes
1 answer

How to escape { in git alias

I'm tryingto write log alias git config --global --replace-all alias.lol6 "! f() { echo "\$1"; git --no-pager log --oneline --graph -15 \${@}; }; f" and use it like this: git lol5 '@{-1}' git log '@{-1}' #works but the commit-ish passged to git…
Boaz Nahum
  • 1,049
  • 8
  • 9
2
votes
1 answer

How can I write a git alias that takes a string as an argument

I would like to write a git alias for: git log --all --grep='Big boi' What I have so far is: [alias] search = "!f() { str=${@}; echo $str; git log --all --grep=$str; }; f" Which echos the string perfectly fine but gives an error, I can't seem…
joshuatvernon
  • 1,530
  • 2
  • 23
  • 45