![git이 스크립트를 실행할 때 사용자 이름을 묻는 이유는 무엇입니까?](https://linux55.com/image/216647/git%EC%9D%B4%20%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8%EB%A5%BC%20%EC%8B%A4%ED%96%89%ED%95%A0%20%EB%95%8C%20%EC%82%AC%EC%9A%A9%EC%9E%90%20%EC%9D%B4%EB%A6%84%EC%9D%84%20%EB%AC%BB%EB%8A%94%20%EC%9D%B4%EC%9C%A0%EB%8A%94%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%3F.png)
Push
이 스크립트를 실행하는 명령이 있습니다 .
FindGits |
{
while read gitFolder; do
parent=$(dirname $gitFolder);
if [[ `git -C $parent status --porcelain` ]]; then
echo;
(
echo $parent;
git -C $parent status --porcelain
git -C $parent add .
git -C $parent commit -m "committed by script" 1>/dev/null 2>/dev/null
if [[ $? == 128 ]]; then
git -C $parent commit -m "commited by script" 1>/dev/null 2>/dev/null
git -C $parent push
if [[ $? == 1 ]]; then
git -C $parent pull
git -C $parent push
fi
else
git -C $parent push
if [[ $? == 1 ]]; then
git -C $parent pull
git -C $parent push
fi
fi
) &
fi
done
wait
}
그러나 실행하면 git이 사용자 이름을 묻습니다.
"https://github.com"의 사용자 이름:
Git이 GitHub에 액세스할 수 있는지 확인하기 위해 수행한 테스트는 다음과 같습니다.
ssh -T [email protected]
=> 성공sudo -i
+ => 성공ssh -T [email protected]
- git 저장소로 가서 몇 가지 항목을 변경하고 수동으로 + 커밋 + 푸시 => 성공을 추가합니다.
- 나는 집으로 돌아가
-C another_git_repo_path
=>를 사용하여 다른 저장소에서 성공적으로 추가 + 커밋 + 푸시를 수행했습니다.
그렇다면 스크립트 내부에서 실행할 때 왜 작동하지 않습니까?
답변1
git 저장소(및 make 등 ) ssh
작업에 인증을 사용하는 경우 대신 인증을 사용하도록 각 저장소를 구성해야 합니다 . 그렇지 않으면 git 명령이 계속해서 사용자와 비밀번호를 묻습니다.pull
push
ssh
https
저장소 인증을 변경하려면 ssh
다음 명령을 사용할 수 있습니다.
git remote set-url origin [email protected]:UserName/Repo.git
- 또는
.git/config
파일에서 해당 행을 다음url = https://github.com/
과 같이 변경할 수 있습니다.url = [email protected]:....
$> cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = [email protected]:UserName/Repo.git # edited line
fetch = +refs/heads/*:refs/remotes/origin/*