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

Use git command inside another git command

So I trying to push changes from my local branch to the remote branch with the same name. And im trying to do something like this. git push origin "git rev-parse --abbrev-ref HEAD" The command inside the quotes return the name of the current…
Vibol
  • 615
  • 1
  • 8
  • 25
2
votes
1 answer

Reference own username in git-alias

I want to list all commits 'since my last commit'. Right now i use this log-alias variant: [user] name = My Name [alias] lg = !git log --since $(git log --pretty=format:'%ct' --author 'My Name' -1) That works fine in general - but i would…
FreedomTears
  • 93
  • 1
  • 6
2
votes
2 answers

Setting a Git alias which uses TR to translate backslash into forward slash

I am trying to set up a Git alias which has to convert a backslash to a forward slash to pass it later to filter-branch command (the need arises since I use Posh and will pass DOS based file path as a parameter). So I have this alias: echo-test =…
Gabrielius
  • 1,045
  • 12
  • 18
2
votes
1 answer

Git alias: how to pass current directory to shell command?

I'm using git bash under Windows, and I would like to make a git alias command that's conceptually something like this: [alias] assume_unchanged_below = "!git ls-files -z $dir | xargs -0 git update-index --assume-unchanged" Where $dir expands…
Chris Kline
  • 2,249
  • 26
  • 32
2
votes
1 answer

Make a git-alias or similar that includes "branchfolder/" - part of the branch name

I just recently discovered how to make git aliases, which are great, but I was wondering if there is a way to include my common branch prefix with the alias. So what I would like is something like: Alias in .gitconfig: [alias] br = checkout -b…
jonasfh
  • 4,151
  • 2
  • 21
  • 37
2
votes
2 answers

git advanced alias parameter issues

Suppose I have this in my .gitconfig alias: testing =!"\ echo \"hi\" \ " if I run git testing 1 4 it will echo the parameters back to me: hi 1 4 Also if I use sh to try to get all the parameters it doesn't show the first: testing =!sh -c 'echo…
newguy
  • 617
  • 6
  • 15
2
votes
1 answer

Configure Alias on Git

I want create more than one command in one line. Example: git fetch && git pull Is possible? This is my .gitconfig: [alias] rb = rebase s = status f = fetch p = pull fp = (git fetch && git pull ???)
fuzeto
  • 207
  • 1
  • 3
  • 8
2
votes
2 answers

How do I ask git to merge branch back to parent

Is there a way to write an alias that merges a branch back to its parent? I know I can do: git checkout - && git merge - But it only works in simple cases when my previous branch is the parent branch. As far as I know git does not track this kind…
fallens4e
  • 443
  • 5
  • 8
2
votes
2 answers

unknown switch 'm' with git alias to commit

In my .gitconfig, I have the following alias: c = add -A && git commit -m The idea is to add all changes and commit them. However, I'm not getting success with this because Git is giving me the message error: unknown switch 'm'.
2
votes
1 answer

Echos in gitconfig aliases echoing the entire list of command line arguments when only one expected

For a long time, I had the following alias in my aliases file: ignore=!([ ! -e .gitignore ] && touch .gitignore) | echo $1 >>.gitignore It wasn't original to me, and if you search for it, you'll see it a lot of places. Recently, however, I've…
Enekk
  • 29
  • 4
2
votes
1 answer

Escape $num in Git aliases

I'm trying to alias a simpler stash so I can do git load , something along this line: load = !git stash list | grep ' $1$' | awk '{ print $1 }' | sed '$ s/:$//'; echo Unfortunately, awk's $1 is being replaced by the stash name too. How…
1
vote
1 answer

Using a local variable in a function when setting a git alias

I am using Windows 11 and git and trying to create a alias which will checkout and pull a branch before checking out the original branch, merging the just pulled branch and then push. I am having trouble setting a local variable for the original…
SBFrancies
  • 3,987
  • 2
  • 14
  • 37
1
vote
2 answers

Documentation and clarification for Git alias shell invocation with arguments

I'm using Git version 2.37.3.windows.1 on Windows 10. From reading the discussion at Git alias with positional parameters and the Git Wiki, I've learned a couple of things about Git aliases: I can invoke a shell command using something like this.…
Garret Wilson
  • 18,219
  • 30
  • 144
  • 272
1
vote
1 answer

Error in getting commit history between two tags - Use '--' to separate paths from revisions

How to get rid of below error to get the commit history? sometimes it works not all the time git log '--pretty=format:%ad - %s [%an]' v1.0.11...b1.0.12 fatal: ambiguous argument 'v1.0.11...b1.0.12': unknown revision or path not in the working…
pruthvi
  • 43
  • 5
1
vote
1 answer

Cannot abort bash script started from a git alias in VSCode using Git Bash

Assume I have a git alias like this: [alias] abortalias = "! f() { \ read -p '> Press ctrl+c to cancel'; \ echo '> This should never be seen'; \ }; \ f" And run git abortalias, then press ctrl+c when prompted. I'm…
Sid
  • 1,709
  • 1
  • 10
  • 17