Git Bash의 Windows 설치에서 ~ 디렉토리 변경
나는 올바른 질문을 있는지 확실하지 않습니다. 내 상황을 설명하겠습니다 :
이것은 Windows 7의 Git에 관한 것입니다.
우리 회사는 로컬 하드 드라이브가 아닌 네트워크 드라이브에 Windows 사용자 디렉토리를 설정합니다 (이 질문의 범위를 벗어난 백업 및 기타 목적으로). 해당 정책을 설명 수 없습니다.
그러나 그 체계는 외부에 로컬 파일을 설정하는 방법입니다. 완전히 지역.
Git을 설치했습니다. Bash를 설치합니다. Bash를 시작하고 cd ~
(루트 디렉토리로 변경) Bash 루트가 네트워크 디렉토리를 사용합니다. 나는 그것을하지 않습니다. 내가 원하는 ~
다른 곳에서 내 하드 드라이브를 사용할 수 있습니다. 인증서, SSH 키 등의 다른 작업을 수행 할 때마다 해당 네트워크를 자동으로 사용하지 않습니다.
나는 어디에서나 헛된 것을 검색하고, 수있는 모든 것이 어디에 있는지, 리디렉션 및 $ HOME이 메시지와 관련된 내용을 검색합니다. 그러나 그것은 내가 원하는 것이 아닙니다.
어디에 있습니까? 그리고 만약이라면 : 어떻게?
업데이트 : 따라서 $ HOME은 수정해야합니다. 그러나이 신화적인 $ HOME 변수가 설치된 위치를 검증 수 있습니다 Linux 시스템 버전의 PATH 또는 다른 가정했습니다. 어쨌든 ...
에 "프로필"파일이 git/etc
있습니다. 내용은 다음과 달라 (공지 없음 $ HOME).
# To the extent possible under law, the author(s) have dedicated all
# copyright and related and neighboring rights to this software to the
# public domain worldwide. This software is distributed without any warranty.
# You should have received a copy of the CC0 Public Domain Dedication along
# with this software.
# If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
# System-wide profile file
# Some resources...
# Customizing Your Shell: http://www.dsl.org/cookbook/cookbook_5.html#SEC69
# Consistent BackSpace and Delete Configuration:
# http://www.ibb.net/~anne/keyboard.html
# The Linux Documentation Project: http://www.tldp.org/
# The Linux Cookbook: http://www.tldp.org/LDP/linuxcookbook/html/
# Greg's Wiki http://mywiki.wooledge.org/
# Setup some default paths. Note that this order will allow user installed
# software to override 'system' software.
# Modifying these default path settings can be done in different ways.
# To learn more about startup files, refer to your shell's man page.
MSYS2_PATH="/usr/local/bin:/usr/bin:/bin"
MANPATH="/usr/local/man:/usr/share/man:/usr/man:/share/man:${MANPATH}"
INFOPATH="/usr/local/info:/usr/share/info:/usr/info:/share/info:${INFOPATH}"
MINGW_MOUNT_POINT=
if [ -n "$MSYSTEM" ]
then
case "$MSYSTEM" in
MINGW32)
MINGW_MOUNT_POINT=/mingw32
PATH="${MINGW_MOUNT_POINT}/bin:${MSYS2_PATH}:${PATH}"
PKG_CONFIG_PATH="${MINGW_MOUNT_POINT}/lib/pkgconfig:${MINGW_MOUNT_POINT}/share/pkgconfig"
ACLOCAL_PATH="${MINGW_MOUNT_POINT}/share/aclocal:/usr/share/aclocal"
MANPATH="${MINGW_MOUNT_POINT}/share/man:${MANPATH}"
;;
MINGW64)
MINGW_MOUNT_POINT=/mingw64
PATH="${MINGW_MOUNT_POINT}/bin:${MSYS2_PATH}:${PATH}"
PKG_CONFIG_PATH="${MINGW_MOUNT_POINT}/lib/pkgconfig:${MINGW_MOUNT_POINT}/share/pkgconfig"
ACLOCAL_PATH="${MINGW_MOUNT_POINT}/share/aclocal:/usr/share/aclocal"
MANPATH="${MINGW_MOUNT_POINT}/share/man:${MANPATH}"
;;
MSYS)
PATH="${MSYS2_PATH}:/opt/bin:${PATH}"
PKG_CONFIG_PATH="/usr/lib/pkgconfig:/usr/share/pkgconfig:/lib/pkgconfig"
;;
*)
PATH="${MSYS2_PATH}:${PATH}"
;;
esac
else
PATH="${MSYS2_PATH}:${PATH}"
fi
MAYBE_FIRST_START=false
SYSCONFDIR="${SYSCONFDIR:=/etc}"
# TMP and TEMP as defined in the Windows environment must be kept
# for windows apps, even if started from msys2. However, leaving
# them set to the default Windows temporary directory or unset
# can have unexpected consequences for msys2 apps, so we define
# our own to match GNU/Linux behaviour.
ORIGINAL_TMP=$TMP
ORIGINAL_TEMP=$TEMP
#unset TMP TEMP
#tmp=$(cygpath -w "$ORIGINAL_TMP" 2> /dev/null)
#temp=$(cygpath -w "$ORIGINAL_TEMP" 2> /dev/null)
#TMP="/tmp"
#TEMP="/tmp"
case "$TMP" in *\\*) TMP="$(cygpath -m "$TMP")";; esac
case "$TEMP" in *\\*) TEMP="$(cygpath -m "$TEMP")";; esac
test -d "$TMPDIR" || test ! -d "$TMP" || {
TMPDIR="$TMP"
export TMPDIR
}
# Define default printer
p='/proc/registry/HKEY_CURRENT_USER/Software/Microsoft/Windows NT/CurrentVersion/Windows/Device'
if [ -e "${p}" ] ; then
read -r PRINTER < "${p}"
PRINTER=${PRINTER%%,*}
fi
unset p
print_flags ()
{
(( $1 & 0x0002 )) && echo -n "binary" || echo -n "text"
(( $1 & 0x0010 )) && echo -n ",exec"
(( $1 & 0x0040 )) && echo -n ",cygexec"
(( $1 & 0x0100 )) && echo -n ",notexec"
}
# Shell dependent settings
profile_d ()
{
local file=
for file in $(export LC_COLLATE=C; echo /etc/profile.d/*.$1); do
[ -e "${file}" ] && . "${file}"
done
if [ -n ${MINGW_MOUNT_POINT} ]; then
for file in $(export LC_COLLATE=C; echo ${MINGW_MOUNT_POINT}/etc/profile.d/*.$1); do
[ -e "${file}" ] && . "${file}"
done
fi
}
for postinst in $(export LC_COLLATE=C; echo /etc/post-install/*.post); do
[ -e "${postinst}" ] && . "${postinst}"
done
if [ ! "x${BASH_VERSION}" = "x" ]; then
HOSTNAME="$(/usr/bin/hostname)"
profile_d sh
[ -f "/etc/bash.bashrc" ] && . "/etc/bash.bashrc"
elif [ ! "x${KSH_VERSION}" = "x" ]; then
typeset -l HOSTNAME="$(/usr/bin/hostname)"
profile_d sh
PS1=$(print '\033]0;${PWD}\n\033[32m${USER}@${HOSTNAME} \033[33m${PWD/${HOME}/~}\033[0m\n$ ')
elif [ ! "x${ZSH_VERSION}" = "x" ]; then
HOSTNAME="$(/usr/bin/hostname)"
profile_d zsh
PS1='(%n@%m)[%h] %~ %% '
elif [ ! "x${POSH_VERSION}" = "x" ]; then
HOSTNAME="$(/usr/bin/hostname)"
PS1="$ "
else
HOSTNAME="$(/usr/bin/hostname)"
profile_d sh
PS1="$ "
fi
if [ -n "$ACLOCAL_PATH" ]
then
export ACLOCAL_PATH
fi
export PATH MANPATH INFOPATH PKG_CONFIG_PATH USER TMP TEMP PRINTER HOSTNAME PS1 SHELL tmp temp
test -n "$TERM" || export TERM=xterm-256color
if [ "$MAYBE_FIRST_START" = "true" ]; then
sh /usr/bin/regen-info.sh
if [ -f "/usr/bin/update-ca-trust" ]
then
sh /usr/bin/update-ca-trust
fi
clear
echo
echo
echo "###################################################################"
echo "# #"
echo "# #"
echo "# C A U T I O N #"
echo "# #"
echo "# This is first start of MSYS2. #"
echo "# You MUST restart shell to apply necessary actions. #"
echo "# #"
echo "# #"
echo "###################################################################"
echo
echo
fi
unset MAYBE_FIRST_START
나는 $HOME
당신이 요구하는 것을 정확하게 해결 하기 때문에 왜 환경 변수 를 설정하고 싶지 않은지 이해하지 못합니다 .
cd ~
디렉토리 루트 로의 변경이 아니라 $HOME
Environmental & 변수에 의해 설정된 user-의 홈 로그인 디렉토리로의 변경을 의미 합니다.
빠른 솔루션
원하는대로 변수를 편집 C:\Program Files (x86)\Git\etc\profile
하고 설정 $HOME
하십시오 (없는 경우 추가하십시오). 좋은 장소는 예를 들어에 의해 언급 된 조건 바로 거기에 있습니다 # Set up USER's home directory
. 예를 들어 MinGW 형식이어야합니다.
HOME=/c/my/custom/home
저장하고 Git Bash를 실행하십시오 cd ~
. 이제 디렉토리에 있어야합니다 /c/my/custom/home
.
사용자 프로파일에 액세스하는 모든 것은 네트워크 드라이브의 Windows 프로파일 대신이 디렉토리로 이동해야합니다.
참고 : C:\Program Files (x86)\Git\etc\profile
모든 사용자가 공유하는 경우 여러 사용자가 기계를 사용하는 경우 $HOME
동적으로 설정하는 것이 좋습니다.
HOME=/c/Users/$USERNAME
세정 솔루션
HOME
Windows에서 환경 변수 를 원하는대로 설정하십시오 . 이 경우 Windows 경로 형식 (예 c:\my\custom\home
:)으로 설정해야합니다 . Git Bash는로드하고 형식으로 변환합니다.
시스템의 모든 사용자에 대한 홈 디렉토리 를 변경 비용 시스템 환경 변수 로 설정하십시오 . 여기서 %USERNAME%
변수 는 예를 들어 모든 사용자가 자신의 홈 디렉토리를 갖도록 변수를 사용할 수 있습니다 .
HOME=c:\custom\home\%USERNAME%
자신만을 위해 홈 디렉토리 를 변경하려는 사용자 환경 변수 로 설정 하여 다른 사용자에게 영향을주지 마십시오. 이 경우 전체 경로를 하드 코딩 할 수 있습니다.
HOME=c:\my\custom\home
나는이 질문에 이미 답을 리포트지만 상황에 처해라는 내가 한 일을 나눌 생각했다. 원래 Git이 아니라 MSYS / MinGW에 대해 작업을 수행했습니다.
HOME
윈도우를 통해 생성하는 것은 내가 영향을주지 않는다. 환경 변수는 일반적으로 Windows 응용 프로그램 설정하지 않습니다. 컴퓨터 속성 (탐색기에서 컴퓨터 또는 이름이 지정된 것을 마우스 오른쪽 버튼으로 클릭하고 속성 또는 할당-> 시스템 및 보안-> 시스템을 선택)에서 선택한 Advanced system settings
다음 Evironment Variables...
새 것을 생성 HOME
합니다. 당신이 원하는 곳에.
새로운 환경 변수를 만들 수있는 다른 답변이 여전히 작동합니다. (나는 찾기가 너무 어렵 기 때문에 환경 변수를 정확하게 작성하는 방법에 대해 자세히 살펴 보았습니다.)
필자의 경우 Windows 에서 다음 사용자 변수 를 추가하기 만하면 됩니다.
변수 이름 : HOME
변수 값 :%USERPROFILE%
환경 변수를 설정하는 방법 ( 시스템 관리자가 아닌 경우 사용자 이름에 사용자 변수 섹션 을 사용할 수 있음 )
전역을 수정하는 대신 다음 내용으로 기본 디렉토리 (예 :)를 profile
만들 수 있습니다 ..bash_profile
$HOME
C:\Users\WhateverUser\.bash_profile
export HOME="C:\my\projects\dir"
cd "$HOME" # if you'd like it to be the starting dir of the git shell
1. Gitbash 바로 가기를 마우스 오른쪽 버튼으로 클릭하여 속성을
선택 합니다. 2. "바로 가기"탭을 선택하십시오.
3. "시작 위치"필드에 시작 디렉토리를 입력하십시오.
4. "대상"필드에서 "--cd-to-home"부분 제거
따라서 $ HOME을 수정해야합니다. 그러나이 신화적인 $ HOME 변수가 설치된 위치를 검증 수 있습니다 Linux 시스템 버전의 PATH 또는 다른 가정했습니다. 어쨌든 ... **
대답
profile
파일 상단에 HOME을 추가하면 효과가 있습니다.
HOME="c://path/to/custom/root/"
.
#THE FIX WAS ADDING THE FOLLOWING LINE TO THE TOP OF THE PROFILE FILE
HOME="c://path/to/custom/root/"
# below are the original contents ===========
# To the extent possible under law, ..blah blah
# Some resources...
# Customizing Your Shell: http://www.dsl.org/cookbook/cookbook_5.html#SEC69
# Consistent BackSpace and Delete Configuration:
# http://www.ibb.net/~anne/keyboard.html
# The Linux Documentation Project: http://www.tldp.org/
# The Linux Cookbook: http://www.tldp.org/LDP/linuxcookbook/html/
# Greg's Wiki http://mywiki.wooledge.org/
# Setup some default paths. Note that this order will allow user installed
# software to override 'system' software.
# Modifying these default path settings can be done in different ways.
# To learn more about startup files, refer to your shell's man page.
MSYS2_PATH="/usr/local/bin:/usr/bin:/bin"
MANPATH="/usr/local/man:/usr/share/man:/usr/man:/share/man:${MANPATH}"
INFOPATH="/usr/local/info:/usr/share/info:/usr/info:/share/info:${INFOPATH}"
MINGW_MOUNT_POINT=
if [ -n "$MSYSTEM" ]
then
case "$MSYSTEM" in
MINGW32)
MINGW_MOUNT_POINT=/mingw32
PATH="${MINGW_MOUNT_POINT}/bin:${MSYS2_PATH}:${PATH}"
PKG_CONFIG_PATH="${MINGW_MOUNT_POINT}/lib/pkgconfig:${MINGW_MOUNT_POINT}/share/pkgconfig"
ACLOCAL_PATH="${MINGW_MOUNT_POINT}/share/aclocal:/usr/share/aclocal"
MANPATH="${MINGW_MOUNT_POINT}/share/man:${MANPATH}"
;;
MINGW64)
MINGW_MOUNT_POINT=/mingw64
PATH="${MINGW_MOUNT_POINT}/bin:${MSYS2_PATH}:${PATH}"
PKG_CONFIG_PATH="${MINGW_MOUNT_POINT}/lib/pkgconfig:${MINGW_MOUNT_POINT}/share/pkgconfig"
ACLOCAL_PATH="${MINGW_MOUNT_POINT}/share/aclocal:/usr/share/aclocal"
MANPATH="${MINGW_MOUNT_POINT}/share/man:${MANPATH}"
;;
MSYS)
PATH="${MSYS2_PATH}:/opt/bin:${PATH}"
PKG_CONFIG_PATH="/usr/lib/pkgconfig:/usr/share/pkgconfig:/lib/pkgconfig"
;;
*)
PATH="${MSYS2_PATH}:${PATH}"
;;
esac
else
PATH="${MSYS2_PATH}:${PATH}"
fi
MAYBE_FIRST_START=false
SYSCONFDIR="${SYSCONFDIR:=/etc}"
# TMP and TEMP as defined in the Windows environment must be kept
# for windows apps, even if started from msys2. However, leaving
# them set to the default Windows temporary directory or unset
# can have unexpected consequences for msys2 apps, so we define
# our own to match GNU/Linux behaviour.
ORIGINAL_TMP=$TMP
ORIGINAL_TEMP=$TEMP
#unset TMP TEMP
#tmp=$(cygpath -w "$ORIGINAL_TMP" 2> /dev/null)
#temp=$(cygpath -w "$ORIGINAL_TEMP" 2> /dev/null)
#TMP="/tmp"
#TEMP="/tmp"
case "$TMP" in *\\*) TMP="$(cygpath -m "$TMP")";; esac
case "$TEMP" in *\\*) TEMP="$(cygpath -m "$TEMP")";; esac
test -d "$TMPDIR" || test ! -d "$TMP" || {
TMPDIR="$TMP"
export TMPDIR
}
# Define default printer
p='/proc/registry/HKEY_CURRENT_USER/Software/Microsoft/Windows NT/CurrentVersion/Windows/Device'
if [ -e "${p}" ] ; then
read -r PRINTER < "${p}"
PRINTER=${PRINTER%%,*}
fi
unset p
print_flags ()
{
(( $1 & 0x0002 )) && echo -n "binary" || echo -n "text"
(( $1 & 0x0010 )) && echo -n ",exec"
(( $1 & 0x0040 )) && echo -n ",cygexec"
(( $1 & 0x0100 )) && echo -n ",notexec"
}
# Shell dependent settings
profile_d ()
{
local file=
for file in $(export LC_COLLATE=C; echo /etc/profile.d/*.$1); do
[ -e "${file}" ] && . "${file}"
done
if [ -n ${MINGW_MOUNT_POINT} ]; then
for file in $(export LC_COLLATE=C; echo ${MINGW_MOUNT_POINT}/etc/profile.d/*.$1); do
[ -e "${file}" ] && . "${file}"
done
fi
}
for postinst in $(export LC_COLLATE=C; echo /etc/post-install/*.post); do
[ -e "${postinst}" ] && . "${postinst}"
done
if [ ! "x${BASH_VERSION}" = "x" ]; then
HOSTNAME="$(/usr/bin/hostname)"
profile_d sh
[ -f "/etc/bash.bashrc" ] && . "/etc/bash.bashrc"
elif [ ! "x${KSH_VERSION}" = "x" ]; then
typeset -l HOSTNAME="$(/usr/bin/hostname)"
profile_d sh
PS1=$(print '\033]0;${PWD}\n\033[32m${USER}@${HOSTNAME} \033[33m${PWD/${HOME}/~}\033[0m\n$ ')
elif [ ! "x${ZSH_VERSION}" = "x" ]; then
HOSTNAME="$(/usr/bin/hostname)"
profile_d zsh
PS1='(%n@%m)[%h] %~ %% '
elif [ ! "x${POSH_VERSION}" = "x" ]; then
HOSTNAME="$(/usr/bin/hostname)"
PS1="$ "
else
HOSTNAME="$(/usr/bin/hostname)"
profile_d sh
PS1="$ "
fi
if [ -n "$ACLOCAL_PATH" ]
then
export ACLOCAL_PATH
fi
export PATH MANPATH INFOPATH PKG_CONFIG_PATH USER TMP TEMP PRINTER HOSTNAME PS1 SHELL tmp temp
test -n "$TERM" || export TERM=xterm-256color
if [ "$MAYBE_FIRST_START" = "true" ]; then
sh /usr/bin/regen-info.sh
if [ -f "/usr/bin/update-ca-trust" ]
then
sh /usr/bin/update-ca-trust
fi
clear
echo
echo
echo "###################################################################"
echo "# #"
echo "# #"
echo "# C A U T I O N #"
echo "# #"
echo "# This is first start of MSYS2. #"
echo "# You MUST restart shell to apply necessary actions. #"
echo "# #"
echo "# #"
echo "###################################################################"
echo
echo
fi
unset MAYBE_FIRST_START
나는 정확히 같은 문제에 직면했다. 내 홈 드라이브가 네트워크 드라이브에 매핑되었습니다. 또한
- 홈 드라이브에 대한 쓰기 권한 없음
- Git bash 프로파일에 대한 쓰기 권한이 없습니다.
- 언어에서 환경 변수를 설명 수있는 관리자 권한이 없습니다.
아래는 명령 줄에서 작동하지만 HOME
환경 변수 에 추가 할 수 있습니다 .
rundll32 sysdm.cpl,EditEnvironmentVariables
그래서
$HOME
수정해야합니다.그러나이 신화
$HOME
변수가 설치된 위치를 검증 수 있는지 Linux 시스템 버전의 PATH 또는 다른 가정했습니다.
Git 2.23 (2019 년 3 분기) HOME
은 설정 방법에 대해 매우 명확합니다 .
Karsten Blees ( )의 commit e12a955 (2019 년 7 월 4 일)를 참조하십시오 . ( Junio C 하마노 에 의해 병합 - 커밋 fc613d2 , 년 7 월 19 일 2,019)kblees
gitster
mingw : 시작시 HOME 초기화
HOME
는 역사적으로 초기화 등 다양한 장소에서 중복 된/etc/profile
발사와 같은 펼쳐,git-bash.vbs
그리고gitk.cmd
, 그리고 (약간 깨진 있지만) 에에git-wrapper
.같은 논리 관련이없는 프로젝트
GitExtensions
와TortoiseGit
같은 논리를 구현하는 경우 직접 마이너스를 호출 할 수 있습니다.초기화
HOME
힘내 자신의 시작 코드에서 우리는 결국 모든 중복 초기화 코드를 폐기 할 수 있도록.
이제 mingw.c는 다음 코드가 포함되어 있습니다.
/* calculate HOME if not set */ if (!getenv("HOME")) { /* * try $HOMEDRIVE$HOMEPATH - the home share may be a network * location, thus also check if the path exists (i.e. is not * disconnected) */ if ((tmp = getenv("HOMEDRIVE"))) { struct strbuf buf = STRBUF_INIT; strbuf_addstr(&buf, tmp); if ((tmp = getenv("HOMEPATH"))) { strbuf_addstr(&buf, tmp); if (is_directory(buf.buf)) setenv("HOME", buf.buf, 1); else tmp = NULL; /* use $USERPROFILE */ } strbuf_release(&buf); } /* use $USERPROFILE if the home share is not available */ if (!tmp && (tmp = getenv("USERPROFILE"))) setenv("HOME", tmp, 1); }
나는 "Gitbash homedir windows"에 대한 Google 결과 제안 내 결과를 추가 할 생각했습니다.
내가 무엇을 시도하든 git-bash를 네트워크 드라이브 (U :) 이외의 곳에서 시작할 수 있습니다. (VPN의 원격 직원, 다른 쪽에서 호스팅되는 네트워크 드라이브)
Windows에서 HOME 및 HOMEDIR 변수를 설정했습니다.
git 설치의 etc / profile 파일에서 HOME 및 HOMEDIR 변수를 설정했습니다.
git-bash 바로 가기에서 "시작"을 C : / user / myusername으로 편집했습니다.
git-bash 쉘 안의 "env"명령은 올바른 c : / user / myusername을 보여줍니다. 그러나 git-bash는 여전히 U에서 시작됩니다.
제거로 나를 위해 고친 것은 git-bash 바로 가기를 편집하고 대상 줄에서 "--cd-to-home"을 제거하는 것이 었습니다.
최신 버전의 Git-for-windows 2.22.0을 실행하는 Windows 10을 사용하고 있습니다.
여기로 이동 : 여기로 이동 : 시스템 복원 지점을 만듭니다. 관리자 계정으로 행사하십시오. C : \ SomeUser 폴더를 삭제하십시오. c : \ Users \ SomeUser 폴더를 c : \ SomeUser가 이동하십시오. 보통 편집기를 다. HKLM \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \ ProfileList로 이동하십시오. c : \ Users \ SomeUser를 사용할 때까지 "ProfileImagePath"를 검색하십시오. c : \ SomeUser를 가리 키도록 수정하십시오. 문제가 보관 된 경우 복원을 사용하십시오.
'IT' 카테고리의 다른 글
R 발광 (0) | 2020.07.24 |
---|---|
cython 및 mingw로 실행하면 gcc가 생성됩니다 : 오류 : 인식 할 수없는 명령 행 옵션 '-mno-cygwin' (0) | 2020.07.24 |
@RequestParam에서리스트 바인딩 (0) | 2020.07.24 |
셀을 채색하지 않고 CSS를 사용하여 테이블 열에 색상을 위임받은 있습니까? (0) | 2020.07.24 |
C ++에서 "X는 형식을 지정하지 않습니다"오류 (0) | 2020.07.24 |