Environment variables in .git/config -


i have git repo created --serparate-git-dir option. use same repo form different working trees specifying --git-dir , --work-tree arguments.

i have 2 working trees switch between added .git file in secondary work tree pointing repository directory. since repository's config file points primary working tree, still have specify explicitly, otherwise uses primary working tree.

i tried setting value of worktree $pwd int .git/config file causes following error: fatal: not chdir '$pwd': no such file or directory

is there way make worktree dynamic?

edit 05-2016 @amynbe comments, git >= 2.5 has git-worktree https://git-scm.com/docs/git-worktree


i have script on freenode passed around, i'm not sure of author know can share, used create different working copyes based on branches, think fit use case:

#!/bin/sh  usage () {         echo "usage:" $@         exit 127 }  die () {         echo $@         exit 128 }  if test $# -lt 2 || test $# -gt 3         usage "$0 <repository> <new_workdir> [<branch>]" fi  orig_git=$1 new_workdir=$2 branch=$3  # want make sure pointed has .git directory ... git_dir=$(cd "$orig_git" 2>/dev/null &&   git rev-parse --git-dir 2>/dev/null) ||   die "not git repository: \"$orig_git\""  case "$git_dir" in .git)         git_dir="$orig_git/.git"         ;; .)         git_dir=$orig_git         ;; esac  # don't link configured bare repository isbare=$(git --git-dir="$git_dir" config --bool --get core.bare) if test ztrue = z$isbare         die "\"$git_dir\" has core.bare set true," \                 " remove \"$git_dir/config\" use $0" fi  # don't link workdir if test -h "$git_dir/config"         die "\"$orig_git\" working directory only, please specify" \                 "a complete repository." fi  # don't recreate workdir on existing repository if test -e "$new_workdir"         die "destination directory '$new_workdir' exists." fi  # make sure links use full paths git_dir=$(cd "$git_dir"; pwd)  # create workdir mkdir -p "$new_workdir/.git" || die "unable create \"$new_workdir\"!"  # create links original repo.  explicitly exclude index, head , # logs/head list since purely related current working # directory, , should not shared. x in config refs logs/refs objects info hooks packed-refs remotes rr-cache svn         case $x in         */*)                 mkdir -p "$(dirname "$new_workdir/.git/$x")"                 ;;         esac         ln -s "$git_dir/$x" "$new_workdir/.git/$x" done  # setup workdir cd "$new_workdir" # copy head original repository default branch cp "$git_dir/head" .git/head # checkout branch (either same head original repository, or # 1 asked for) git checkout -f $branch 

Comments

Popular posts from this blog

c++ - OpenMP unpredictable overhead -

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

javascript - Wordpress slider, not displayed 100% width -