Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6140355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:06:29+00:00 2026-05-23T18:06:29+00:00

If you specify GIT_DIR=.git2 it will only specify this as relative to the current

  • 0

If you specify GIT_DIR=”.git2″ it will only specify this as relative to the current directory. And in this case it will not do the “search up until the first parent dir that contains a ‘.git2′” protocol as it does with the default ‘.git’.

Also if you specify a full path like /home/me/project/.git2 it will not add and commit files to a path in the repository relative to the location of the ‘.git2’.

So the question – is there a way to substitute the folder name git uses to some other name than ‘.git’ and have all other aspects of the protocol work exactly the same way as they do with the default ‘.git’ name ???

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:06:30+00:00Added an answer on May 23, 2026 at 6:06 pm

    If you want to do this for a particular repository:

    export GIT_DIR=/home/me/project/.git2
    export GIT_WORK_TREE="$(dirname "${GIT_DIR}")"
    git ...
    

    or:

    git --git-dir=/home/me/project/.git2 --work-tree=/home/me/project ...
    

    If you want to change the default name of the Git directory everywhere, you can do something convoluted like this:

    git() (
        # if GIT_DIR is set, honor it
        [ -z "${GIT_DIR+set}" ] || { command git "$@"; exit $?; }
    
        # find GIT_DIR
        GIT_DIR=$(
            : "${GIT_DIR_NAME=.git2}"
            while true; do
                [ -d "${GIT_DIR_NAME}" ] && {
                    printf '%s\n' "${PWD%/}/${GIT_DIR_NAME}"
                    exit 0
                }
                [ "$(pwd -P)" != / ] || {
                    echo "fatal: Not a git repository" >&2
                    exit 1
                }
                cd .. || exit 1
            done
        ) || exit 1
    
        # set GIT_WORK_TREE based on GIT_DIR if it is not already set
        [ -n "${GIT_WORK_TREE+set}" ] || {
            GIT_WORK_TREE=$(dirname "${GIT_DIR}") || exit 1
        }
    
        # run the actual git with the discovered directories
        GIT_DIR=${GIT_DIR} GIT_WORK_TREE=${GIT_WORK_TREE} command git "$@"
    )
    

    With the above, when you run git foo it’ll search for .git2 instead of .git. For the working directory, it’ll use the directory containing .git2.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I do not specify the following in my web.xml file: <session-config> <session-timeout>10</session-timeout> </session-config>
I'm trying to use this env variable to specify the path for my templates
I'm getting the warning warning: You did not specify any refspecs to push, and
I run rails new search in my console, and I get all of this:
I'm looking for a way to specify that a subset of files should not
Background: the current text editor i am using does not have built-in support for
With Git , I know you can specify only to selectively fetch a few
How do you specify that a foreign key constraint should be a 1:1 relationship
XAML allows you to specify an attribute value using a string that contains curly
How do you specify a target framework version for the csc.exe c# compiler via

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.