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
2 answers

Git alias which uses aliases

I would like to use the assume command in order to chain it 5 times. [alias] assume = update-index --assume-unchanged unassume = update-index --no-assume-unchanged assumeall = "!git ls-files ../.idea/misc.xml | xargs git assume" unassumeall = "!git…
JY2k
  • 2,879
  • 1
  • 31
  • 60
1
vote
1 answer

Using backtick command execution in Git alias

Here's a simple example to demonstrate my problem. If I do: git commit -m "`date --utc`" It executes date --utc, and puts the result inside the commit message. However, when I alias it to testcomit: git config --global alias.testcommit 'commit -m…
Saeb Amini
  • 23,054
  • 9
  • 78
  • 76
1
vote
2 answers

Git alias for combining multiple commands: git checkout and git status

I find that every time I checkout a local branch, I do a git status. I want to add a git status to my alias for checkout to be more efficient. I already have the following simple alias for checkout: alias.co=checkout I'd like to modify it so that…
well actually
  • 11,810
  • 19
  • 52
  • 70
1
vote
1 answer

Git: Creating alias for "add --update TOPLEVEL_DIR"?

I often find myself typing git add -u with the intention of adding everything that is modified but tracked in the whole repository. However, it gets annoying and tedious when I'm in a subdirectory. For example if all my modifications are in src/…
eold
  • 5,972
  • 11
  • 56
  • 75
1
vote
1 answer

git alias with formatting in .gitconfig

I've tried to do almost the same as described here, with same problems: Creating a 'git log' alias with formatting Solutions from this topic, of course, works. But let say I want to group my git functions in git namespace, that is, to run git gl…
jeron-diovis
  • 788
  • 1
  • 8
  • 19
1
vote
3 answers

Is there a git command that attempts a pull before pushing everytime?

When I work on git repositories by myself, there is no reason to ever pull before pushing. When I work with others, it is recommended that I perform a pull before attempting to push-- well, either a pull, or a checkout, and then get the changes…
Trevor Hickey
  • 36,288
  • 32
  • 162
  • 271
1
vote
2 answers

git alias for creating a .gitattributes on init - how do I add the new lines?

My latest iteration jinit= !git init && printf "* text=auto\n*.java text\n*.jsp text\n*.css text\n*.html text\n*.js text\n*.xml text\n*.sql text\n*.MF text\n*.tld text\n*.md text\n\n# git files\n*.gitignore text\n*.gitattributes text\n\n# eclipse…
Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361
1
vote
1 answer

Bang aliases don't work

I tried to add some bang aliases (say... !git stash pop). But those does not work. [alias] pop = !git stash pop This unfortunatelly does not work (please ignore the fact I can use it without the bang - I needed a command to test it. My alias…
Tomáš Fejfar
  • 11,129
  • 8
  • 54
  • 82
1
vote
1 answer

git alias to merge and then rollback merged files as uncommitted

I'm using git on Windows and I'd like to define an alias for the following workflow: git merge git reset HEAD~1 I tried the following in my got config file but it does something different than executing the 2 commands separately [alias] …
Damian
  • 2,709
  • 2
  • 29
  • 40
1
vote
1 answer

Git (on Windows using msysgit) - "compound" command

I need to do several "two-step" or "three-step" commands in Git quite frequently, that require me to also specify a branch name as a parameter - things like: git checkout (branch name) git pull origin (branch name) or stuff like that. I would like…
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
0
votes
0 answers

git alias not accepting shell command, Does it have any solution?

Working alias for ref: git config --global alias.br "branch -vva" The below alias not working git config --global alias.br "branch -vva | awk '{print $1}'" The Git alias is not working after adding awk in command. Does it have any fix for…
JOEL
  • 29
  • 7
0
votes
1 answer

Git won't recognize aliases from local config file

Issue: I have manually added a simple alias in ~/.gitconfig (git version 2.38.1.windows.1), and it looks like this: [alias] lg = !git log --oneline --graph -$1 # I use it as follows (expecting to get the equivalent result of typing git log…
CreepyRaccoon
  • 826
  • 1
  • 9
  • 19
0
votes
1 answer

Create a Git Alias specific to one project

I have a Python project that is compiled using pyinstaller. It usually uses a bunch of concatenated operations && to not only compile, but perform several other things. Ok, just a big command. I can use an alias with git bash to reduce it to a…
Alex Vergara
  • 1,766
  • 1
  • 10
  • 29
0
votes
1 answer

Bash completion for git aliases containing multiple subcommands

I have set up the following alias in my .gitconfig file: [alias] ss = stash show Unfortunately bash completion does not work correctly on this alias. When I type git ss , I get: ❯ git ss apply clear drop pop show …
carlfriedrich
  • 2,919
  • 1
  • 15
  • 29
0
votes
3 answers

Alias git branches to replace "master" with "main"

I work on a bunch of different repos - many of them use master, and many of them use main. I also have various shell aliases set up for git commands, e.g. gcm for git checkout master. The problem is that I cannot use these aliases on repos where…
max pleaner
  • 26,189
  • 9
  • 66
  • 118