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

How to add custom named arguments to git aliases

Currently my git aliases all have to depend on the arguments being passed in a specific order, accessing them with $1, $2, etc. What I would want to do is something like git sync --from="dev" --to="uat" Where sync is the alias where I would want to…
Valyrion
  • 2,342
  • 9
  • 29
  • 60
0
votes
2 answers

Cannot create git alias for first commit

I've been struggling for a while trying to create the following alias (displays the very first commit of the tree's history) in my .gitconfig : [alias] first = log $(git log --pretty=format:%H|tail -1) However, I get the following…
teobais
  • 2,820
  • 1
  • 24
  • 36
0
votes
0 answers

Alias for checking out branch only if it exist in remote

How can I make alias that checks out branch from remote only if it exists. In other words, how can I suppress If is not found but there does exist a tracking branch in exactly one remote (call it ) with a matching name, treat as…
kuskmen
  • 3,648
  • 4
  • 27
  • 54
0
votes
1 answer

How can I create a git alias to delete a tag remotely?

I'm having trouble creating a git alias to delete a tag remotely. I have the following in my .gitconfig: [alias] deltag = push origin :refs/tags/$1 Running the deltag alias after deleting a tag locally (with git tag -d testtag) results in this…
Tim Malone
  • 3,364
  • 5
  • 37
  • 50
0
votes
2 answers

git alias for a full reset to HEAD

I have the following git aliases: [alias] b = branch p = push co = checkout cm = commit -m cmall = !git add -A && git commit -m cob = checkout -b …
codyc4321
  • 9,014
  • 22
  • 92
  • 165
0
votes
1 answer

Why doesn't this git alias to find remote branches work?

I'm on Windows Command Prompt (don't judge). I have this command: git remote show origin | grep \w*\s*(new^|tracked) -E This works fine, printing what I expect: dev tracked master …
Anubian Noob
  • 13,426
  • 6
  • 53
  • 75
0
votes
0 answers

Commands in a Git Script Functions (Windows) Not Working As Expected in Sub Folder Under a Git Repo

I have the following folder structure... \GitRepo \.git [files] \IgnoredFolder #ignored from .gitignore \SubRepo I'm trying to right a script function in my .gitconfig file and I need to know the current directory, but I'm…
Terry
  • 2,148
  • 2
  • 32
  • 53
0
votes
1 answer

git alias: Parameter doesn't work

I figured out that git branch | grep | cut -d' ' -f2 will give me the name of a branch that contains the substring . I'm trying to put this command in a git alias, like so: [alias] gb = "!f(){ git branch | grep $1 | cut…
Jay Bienvenu
  • 3,069
  • 5
  • 33
  • 44
0
votes
2 answers

Using Git Add with files that maybe don't exist

On Windows, I'm trying to create an alias for Git Add to automatically select only C# related files. My current alias is: acs = add *.cs *.csproj *.sln I keep getting this error: fatal: pathspec '*.sln' did not match any files, which is expected,…
0
votes
1 answer

Git append the current commit hash to result of a commit command

I want to append the hash of the ongoing commit to its result. I can retrieve the hash using this command: git log --format=%H | tail -1 Then I try to merge a commit with command above and make an alias in '.gitconfig', like this: [alias] ci =…
farzan
  • 1,160
  • 2
  • 14
  • 25
-1
votes
2 answers

Passing an argument to git alias not working

I created the following alias on Windows 10 to issue a commit -am command. I used the the $1 token to register an argument, but it is not working. git config --global alias.cam 'commit -am $1' Issuing the following command returns…
Raj Narayanan
  • 2,443
  • 4
  • 24
  • 43
1 2 3 4 5 6 7
8