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
1
vote
3 answers

echo arbitrary arguments in git

I am chaining a bunch of git commands in alias as below. How do I get the 'echo' part to work: [alias] comb = ! sh -c 'echo \"Combining branches $1 with $2\"' && git checkout $2 && git merge $1 && git push && git checkout $1 && : Some…
Kap4Lin
  • 109
  • 5
1
vote
7 answers

Create a git command to open repository in browser

I want to create a git alias which will allow me to do git visit and the repository will be opened in the browser.
Jonathan1609
  • 1,809
  • 1
  • 5
  • 22
1
vote
1 answer

git submodule foreach not working as alias

I used to use commands like git submodule foreach git status or for commands that may fail git submodule foreach "git checkout develop || true" So now I created a alias for the first form and it works OK git config --global alias.all '!f(){ git…
amsmota
  • 171
  • 2
  • 11
1
vote
1 answer

How to fix : Command not found - Git Alias

I'm trying to setup a git alias to list all files that are marked 'assume-unchanged' with this command: git ls-files -v | sls -pattern ^h -casesensitive When i use this command directly in powershell it works as expected but as an alias i get the…
1
vote
1 answer

How can I set multiple pager options for the same command in git?

I want to be able to launch git diff with two different pagers on demand. The only way I know is updating the git config and launching the command (or updating the GIT_PAGER variable). Example of .gitconfig: core.pager = cat [Alias] def-pager =…
Jorge
  • 21
  • 5
1
vote
1 answer

Parse branch name, initiate commit with name in the commit message

My team uses a common naming convention for branch names, which include the Jira task number in the branch name. feature/ACD-1664_update-api-call feature/VZ-1943_new-provider-template hotfix/RV-977_fix-loading-issue I want to create a git alias…
Joshua Soileau
  • 2,933
  • 9
  • 40
  • 51
1
vote
1 answer

How to add author name to a custom git alias?

I have configured custom git alias that I use very frequently to see the complete graph and commit summary. [alias] graph = log --oneline --all --decorate --graph One thing I would like to add to this alias is the author name. I am trying to…
Afraz Ali
  • 2,672
  • 2
  • 27
  • 47
1
vote
2 answers

Git commit --amend alias causing a rebase

I'm wondering why my git alias got stuck and how it caused a rebase. Steps to reproduce: git config --global alias.am "commit --amend" I can see that the alias is added with: git config --global -e [alias] am = commit --amend --no-edit Create…
Alex Telon
  • 1,107
  • 1
  • 14
  • 30
1
vote
2 answers

Adding more complex scripts as Git aliases doesn't work due to parser errors

In Git, I want to add some global aliases for convenience. The command git config --global alias.unstage 'reset HEAD --' as found in the documentation, works fine. So I tried using that same syntax, with a ! prepended to the command, to run…
caw
  • 30,999
  • 61
  • 181
  • 291
1
vote
1 answer

git bad config when piping commands

Both of these commands work from the command line git symbolic-ref HEAD | sed -e "s#^refs/heads/##" and git branch | grep \* | cut -d ' ' -f2 When added to gitconfig under [alias] thisbranch = !git symbolic-ref HEAD | sed -e…
MikeF
  • 764
  • 9
  • 26
1
vote
3 answers

Is there a way to create a shortcut or alias for git option(s)

I find myself using --name-status option a lot with git log, git diff, git show. I'm aware of git aliases but they only work for a command or a combination of command and/or option(s). I do not want to create git aliases just for this option. # l is…
hIpPy
  • 4,649
  • 6
  • 51
  • 65
1
vote
2 answers

git clone all branches bash script as git alias

I would like to create a git alias that clones all branches. We have the bash script, thanks to this post: How to clone all remote branches in Git? Here is the bash script (multi-line version): #!/bin/bash for branch in $(git branch --all |…
Kobi
  • 4,003
  • 4
  • 18
  • 23
1
vote
2 answers

Nest backticks inside a git command alias

I'm attempting to make a git alias to show all commits since the last tag. I'm basing it of this SO answer that I've used a lot in the past. Currently, I'm trying this with a git config --global alias.* command like so: git config --global…
matthewrdev
  • 11,930
  • 5
  • 52
  • 64
1
vote
2 answers

Error after adding an alias in global .gitconfig

I've added a line in my .gitconfig file on Windows: [alias] hist = log --pretty=format:"%C(yellow)%h [%ad]%C(reset) | %s%d %C(green)(%cr)%C(reset) by %C(blue)%an%C(reset)" --graph --all --decorate --date=short This code works fine if I use it from…
kekyc
  • 317
  • 6
  • 15
1
vote
0 answers

git alias with ...&& git push command won't push

I have an alias of: $HOME/.gitconfig: [alias] ... cmall = !git add -A && git commit -m $1 && git push which looks correct from what I've read, but the git push part isn't working: (repo)me:~/work_projects/repo$ git cmall…
codyc4321
  • 9,014
  • 22
  • 92
  • 165