2017-09-27 4 views
0

Bash 스크립트를 사용하여 리파지토리를 리파지하는 방법을 찾으려하고 있습니다 만,이 방법을 사용하면 버그를 수정하는 방법을 모르는 몇 가지 오류가 많이 있습니다. : ./bash.sh: line 3: $'\r': command not foundGit 리포지토리를 리베이스하는 Bash 스크립트

오류 : - 창 캐리지 리턴이 유엔에 다른 여기

./bash.sh: line 3: $'\r': command not found 
./bash.sh: line 6: $'\r': command not found 
Updating Repo: /home/teste/ with url: 
./bash.sh: line 8: $'\r': command not found 
./bash.sh: line 16: syntax error near unexpected token `$'\r'' 
'/bash.sh: line 16: `(git fetch --all && git stash) 

내가 그것은 스크립트 자체 파일 인코딩이 아니다

directory="/home/teste/" ## Where the server is located 
original_dir="/root" ## Where we should back after the pull 

cd $directory # switch to the git repo 
repo_url=$(git config --get remote.origin.url) 

echo "Updating Repo: $directory with url: $repo_url" 

main_branch="master" 
if [ "$repo_url" == "XXXXX" ]; then # if you have a repo where the primary branch isnt master 
    $main_branch="trunk" 
fi 

# update the repo, then stash any local changes 
echo -e "\ncalling: git fetch --all && git stash" 
(git fetch --all && git stash) 
current_branch=$(git rev-parse --abbrev-ref HEAD) 

# switch to master/trunk branch and rebase it, then switch back to original branch 
if [ $current_branch != $main_branch ]; then 
    echo -e "\ncalling: git checkout $main_branch && git rebase && git checkout $current_branch" 
    (git checkout $main_branch && git rebase && git checkout $current_branch) 
fi 

# rebase the original branch and then stash pop back to original state 
echo -e "\ncalling: git rebase && git stash pop on branch: $current_branch" 
(git rebase && git stash pop) 

#switch back to the starting directory 
cd $original_dir 
echo "" 
+0

우선 저장소를 리베이스하지 않으면 분기를 리베이스합니다. 그러나 제쳐두고 리베이스는 매우 복잡한 프로세스가 될 수 있으며, 병합이 발생할 수 있으며 종종 그렇게됩니다. bash 스크립트에서 병합 충돌을 어떻게 처리 할 계획입니까? –

답변

1

을받은 스크립트입니다 ix 형식. GUI 편집기를 사용하는 경우 OS에 따라 줄 끝 문자를 'unix'또는 'win'형식으로 변경하십시오.

또한 dos2unix라는 도구를 사용하여 파일에 대해 실행하여 줄 끝을 유닉스 형식으로 변환하거나 unix2dos로 변환 할 수 있습니다.

.gitattributes 구성에서 원하는 형식을 설정할 수도 있습니다.

text eol=crlf # unix 

또는

text eol=lf # windows 

참조 : https://help.github.com/articles/dealing-with-line-endings/

피부이 고양이에 다른 방법이 페이지를 참조하십시오 이것은 당신이 체크 아웃하고 커밋 코드가 미래에 따라 처리됩니다 것 . '\r': command not found - .bashrc/.bash_profile

+1

감사! 그게 문제 였어! – vankk