Moving directories for portable git configuration

I have installed the portable git version on my flash drive, but I don’t want my repository to be in the same directory as the program. I can get to the directory using:

$ git -- git-dir=../Gits --work-tree=..Gits

But I don’t want to enter that every time. So I found in this article on the gitconfig file. But it only shows how to set the core.worktree

  • TeamCity fails to trigger on wildcard-specified branch
  • git add all except ignoring files in .gitignore file
  • When I have git log print out as oneline, how do I reverse it?
  • How to generate a log entry on master when creating and deleting a dev branch?
  • How do I keep my local version of files, without using .gitignore?
  • How to remove GitHub commit along with it's history?
  • core.worktree

    Set the path to the root of the work tree. This can be overridden by
    the GIT_WORK_TREE environment variable
    and the –work-tree command line
    option. It can be an absolute path or
    a relative path to the .git directory,
    either specified by –git-dir or
    GIT_DIR, or automatically discovered.
    If –git-dir or GIT_DIR are specified
    but none of –work-tree, GIT_WORK_TREE
    and core.worktree is specified, the
    current working directory is regarded
    as the root of the work tree.

    Note that this variable is honored even when set in a configuration file
    in a “.git” subdirectory of a
    directory, and its value differs from
    the latter directory (e.g.
    “/path/to/.git/config” has
    core.worktree set to
    “/different/path”), which is most
    likely a misconfiguration. Running git
    commands in “/path/to” directory will
    still use “/different/path” as the
    root of the work tree and can cause
    great confusion to the users.

    I have tried these settings to no avail.

      worktree = ../Gits
      gitdir = ../Gits

    Does anyone know a way to set the git-dir and work-tree directories for PortableGit- for Windows so I don’t have to type that in all the time?

    Also is there a way to add the passphrase so I don’t have to type that in either? I saw these instructions, but the portable version apparently doesn’t have a ~/.profile or ~/.bashrc file.

  • JGIT Pull NoHeadException
  • Dynamic Grunt involving n subdirectories
  • OpenCV 3.0.0 make error with FFMPEG
  • Is there a program (or sed script) that will remove a function from a C file?
  • Remove large .pack file created by git
  • Git merge while discarding any previous changes(In local repository or from the last commit)
  • One Solution collect form web for “Moving directories for portable git configuration”

    Why would any git repo in the same directory than your portable installation?

    As long as your %PATH% reference your portable Git/cmd directory, you can just type ‘git whatever‘ in your Git repo anywhere, and the working directory and git directory will be at their default places.

    And any Git version has access to ~/.profile or ~/.bashrc: open a Git bashrc, and type cd, then pwd: the path displayed is your ‘~‘.
    Then, if you have no .profile or .bashrc yet, create one, put it it a simple echo (echo .profile in the .profile file, ‘echo .bashrc‘ in the .bashrc), open another Git bashrc and check if your .profile/.bashrc are activated.

    Git Baby is a git and github fan, let's start git clone.