git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Git Alias not working in worktree

From
FIFrank Illenseer <illenseer@altair.de>
Date
Sep 25, 2020, 16:44 UTC
Message-ID
<DM5PR03MB2826C04CC5AAF3B61BDDAFE2B5360@DM5PR03MB2826.namprd03.prod.outlook.com>
In-Reply-To
<DM5PR03MB2826A616AC30710E169B7237B5360@DM5PR03MB2826.namprd03.prod.outlook.com>
Dear Git User-group,

I am having a setup where I use worktrees and I was now experimenting with adding git aliases to work more efficiently with the commands. However I found that obviously it does not seem to work like I would like to have it:

My intention is to have a ".gitconfig" file as part of the repo so that all developers can easily get to the same configuration that was setup and also to have the config tracked as part of the repo. We are using Git for Windows v2.28 and also git 2.28 on Linux.

I printed my config from my windows machine below.
You will also see that I have two aliases defined now at two places:
-  The "sts" alias in an include file from my personal .gitconfig ni my HOME
-  The "st" alias in the include file that is part of the repository which is included in the config of the worktree

Only the "sts" alias is recognized by git and works, while the "st" is unknown. But both of the aliases show equally in the below "git config -list".

WHY is the one working and the other one not! HOW can I get both working equally?

Any hints or help is greatly appreciated. Thanks and best regards, Frank

me@MYPC /c/WORK/my_src/wt_KER-dev-B (Features/2.1/gitUtilities|SPARSE) $ git config --list --show-origin file:D:/Programs/GitForWindows/etc/gitconfig    http.sslcainfo=D:/Programs/GitForWindows/mingw64/ssl/certs/ca-bundle.crt file:D:/Programs/GitForWindows/etc/gitconfig    http.sslbackend=openssl file:D:/Programs/GitForWindows/etc/gitconfig    diff.astextplain.textconv=astextplain file:D:/Programs/GitForWindows/etc/gitconfig    filter.lfs.clean=git-lfs clean -- %f file:D:/Programs/GitForWindows/etc/gitconfig    filter.lfs.smudge=git-lfs smudge -- %f file:D:/Programs/GitForWindows/etc/gitconfig    filter.lfs.process=git-lfs filter-process file:D:/Programs/GitForWindows/etc/gitconfig    filter.lfs.required=true file:D:/Programs/GitForWindows/etc/gitconfig    credential.helper=manager file:D:/Programs/GitForWindows/etc/gitconfig    core.autocrlf=true file:D:/Programs/GitForWindows/etc/gitconfig    core.fscache=true file:D:/Programs/GitForWindows/etc/gitconfig    core.symlinks=false file:D:/Programs/GitForWindows/etc/gitconfig    pull.rebase=false file:C:/Users/myaccount/.gitconfig       user.name=My Name file:C:/Users/myaccount/.gitconfig       mailto:user.email=me@comp.de file:C:/Users/myaccount/.gitconfig       receive.denycurrentbranch=updateInstead file:C:/Users/myaccount/.gitconfig       include.path=.gitconfig.aliases file:C:/Users/myaccount/.gitconfig.aliases       alias.sts=status -s file:C:/WORK/my_src/_MAIN/.git/config core.repositoryformatversion=1 file:C:/WORK/my_src/_MAIN/.git/config core.filemode=false file:C:/WORK/my_src/_MAIN/.git/config core.bare=false file:C:/WORK/my_src/_MAIN/.git/config core.logallrefupdates=true file:C:/WORK/my_src/_MAIN/.git/config core.ignorecase=true file:C:/WORK/my_src/_MAIN/.git/config core.symlinks=true file:C:/WORK/my_src/_MAIN/.git/config core.longpaths=true file:C:/WORK/my_src/_MAIN/.git/config mailto:remote.origin.url=git@gitlab.xyz.com:project.git file:C:/WORK/my_src/_MAIN/.git/config remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* file:C:/WORK/my_src/_MAIN/.git/config branch.master.remote=origin file:C:/WORK/my_src/_MAIN/.git/config branch.master.merge=refs/heads/master file:C:/WORK/my_src/_MAIN/.git/config extensions.worktreeconfig=true file:C:/WORK/my_src/_MAIN/.git/config fetch.prune=true file:C:/WORK/my_src/_MAIN/.git/config fetch.prunetags=true file:C:/WORK/my_src/_MAIN/.git/worktrees/wt_KER-dev-B/config.worktree include.path=C:/WORK/my_src/wt_KER-dev-B/.gitconfig file:C:/WORK/my_src/wt_KER-dev-B/.gitconfig   core.hookspath=devops/git/hooks file:C:/WORK/my_src/wt_KER-dev-B/.gitconfig   core.longpaths=true file:C:/WORK/my_src/wt_KER-dev-B/.gitconfig   extensions.worktreeconfig=true file:C:/WORK/my_src/wt_KER-dev-B/.gitconfig   fetch.prune=true file:C:/WORK/my_src/wt_KER-dev-B/.gitconfig   fetch.prunetags=true file:C:/WORK/my_src/wt_KER-dev-B/.gitconfig   alias.st=status file:C:/WORK/my_src/_MAIN/.git/worktrees/wt_KER-dev-B/config.worktree core.sparsecheckout=true

me@MYPC /c/WORK/my_src/wt_KER-dev-B (Features/2.1/gitUtilities|SPARSE) $ git st git: 'st' is not a git command. See 'git --help'.

The most similar commands are
        status
        sts

me@MYPC /c/WORK/my_src/wt_KER-dev-B (Features/2.1/gitUtilities|SPARSE) $ git sts M .gitconfig M devops/python/modules/gitUtilities.py

Next: brian m. carlson
Message 1 of 6 in “Git Alias not working in worktree”
  1. Frank IllenseerSep 25, 2020
  2. brian m. carlsonSep 25, 2020
  3. Frank IllenseerOct 7, 2020
  4. Frank IllenseerOct 22, 2020
  5. Eric SunshineOct 22, 2020
  6. Randall S. BeckerOct 22, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.