inflearn logo
강의

講義

知識共有

素早くgit - コアだけを選んで学ぶGit/Github

커밋 관련 질문

702

castie

投稿した質問数 7

1

제가 파이썬 코드를 push  하려는데

파일 이름에 괄호 같은 특수문자가 있으면 push가  안되나요?

git add . 로 하면 되긴 하는데

해당 파일만 push하려고 이름을 직접 적었을때는 error가 뜨더라구요

답변 주시면  감사하겠습니다!

버전관리시스템 git github

回答 5

1

castie

user@DESKTOP-SFQ7A3T MINGW64 ~/0_Jupyter_Notebook/Kaggle (master)

$ git init

Reinitialized existing Git repository in C:/Users/user/0_Jupyter_Notebook/Kaggle/.git/

user@DESKTOP-SFQ7A3T MINGW64 ~/0_Jupyter_Notebook/Kaggle (master)

$ git status

On branch master

Your branch is up to date with 'origin/master'.

Changes not staged for commit:

  (use "git add/rm <file>..." to update what will be committed)

  (use "git restore <file>..." to discard changes in working directory)

        modified:   .ipynb_checkpoints/0602_Dietanic(EDA)-checkpoint.ipynb

        deleted:    0602_Dietanic.ipynb

Untracked files:

  (use "git add <file>..." to include in what will be committed)

        0602_Dietanic(EDA).ipynb

no changes added to commit (use "git add" and/or "git commit -a")

user@DESKTOP-SFQ7A3T MINGW64 ~/0_Jupyter_Notebook/Kaggle (master)

$ git add 0602_Dietanic(EDA).ipynb

bash: syntax error near unexpected token `('

맨 밑에 이렇게 뜹니다ㅠ

0

kangminchul

윈도우와 유닉스/리눅스계열 시스템에서 End-of-line(개행문자)의 차이때문에 생기는 경고입니다.

bash는 유닉스 계열의 환경을 재현한 프로그램으로, End-of-line(개행문자)이 LF로 표시됩니다.

(참고로 이를 Line Feed라고 합니다.)

하지만 실제로 작업해서 git add commit push 하려는 대상은 Windows에서 만들어졌죠?

Windows에서는 End-of-line을 CRLF(carriage return, line feed)로 표시합니다. 

때문에 

"너가 Windows에서 작성한 파일의 개행문자는 CRLF인데, 

bash (유닉스시스템)에서는 이걸 LF로 바꿔 인식할거야~"

를 말해주는 경고메세지라고 보시면 됩니다. 

추가로, 이 메세지를 보고 싶지 않으시다면 

git config core.autocrlf true

명령어를 입력해주세요!

0

castie

네  아마 된것 같습니다!

그런데 warning 이라고 뜨는데 어떤 내용인지 알려주실 수 있나요?

user@DESKTOP-SFQ7A3T MINGW64 ~/0_Jupyter_Notebook/Kaggle (master)

$ git add 0602_Dietanic\(EDA\).ipynb

warning: LF will be replaced by CRLF in 0602_Dietanic(EDA).ipynb.

The file will have its original line endings in your working directory

user@DESKTOP-SFQ7A3T MINGW64 ~/0_Jupyter_Notebook/Kaggle (master)

$ git status

On branch master

Your branch is up to date with 'origin/master'.

Changes to be committed:

  (use "git restore --staged <file>..." to unstage)

        new file:   0602_Dietanic(EDA).ipynb

Changes not staged for commit:

  (use "git add/rm <file>..." to update what will be committed)

  (use "git restore <file>..." to discard changes in working directory)

        modified:   .ipynb_checkpoints/0602_Dietanic(EDA)-checkpoint.ipynb

        deleted:    0602_Dietanic.ipynb

0

kangminchul

$ git add 0602_Dietanic\(EDA\).ipynb

이와 같이 입력해보세요 :) 

참고로 백슬래시 \ (혹은 원화 표시)는

"이 다음에 특수문자/예약어로 오해받을 수도 있는 단어를 쓸건데, 이건 그냥 문자열이니까 오해하지마~"

라는 의미를 담고 있습니다.

즉,

git add 0602_Dietanic(EDA).ipynb 

라고만 하면, git은 

"잉? ( 이거 뭐지?  갑자기 웬 소괄호지? " 하고 syntax error near unexpected token `(' 라는 에러를 띄우지만,

git add 0602_Dietanic\(EDA\).ipynb 

라고 입력하면, git은 "아~ 소괄호들은 그냥 파일이름(문자열)이구나" 하고 인식하는거죠.

(참고로 이를 'escape sequence'라고 합니다 )

팁을 드리자면, git add 까지만 치고, TAB키(자동완성키)를 눌러보세요! 그럼 자동으로 

$ git add 0602_Dietanic\(EDA\).ipynb

이렇게  표시될겁니다~

도움이 되었길 바랍니다!

0

kangminchul

minchul@DESKTOP-N87KQ5N MINGW64 ~/Desktop/test (master)
$ ls
'(hello).txt' 

minchul@DESKTOP-N87KQ5N MINGW64 ~/Desktop/test (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        (hello).txt

nothing added to commit but untracked files present (use "git add" to track)

minchul@DESKTOP-N87KQ5N MINGW64 ~/Desktop/test(master)
$ git add .

minchul@DESKTOP-N87KQ5N MINGW64 ~/Desktop/test (master)
$ git commit -m "new flie"
[master f939eb1] new flie
 1 file changed, 1 insertion(+)
 create mode 100644 (hello).txt

minchul@DESKTOP-N87KQ5N MINGW64 ~/Desktop/test (master)
$ git push
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 290 bytes | 290.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/kangtegong/test.git
   4503ea6..f939eb1  master -> master


음 저는 문제없이 잘 push 되는 것 같습니다만,

흔히 파일 이름에 특수 문자를 사용하는 것은 권장하는 사항은 아닙니다 :)

혹시 어떤 에러메세지가 뜨시나요?

pull request에 관해

0

35

1

로컬과 원격의 상호작용 강의 질문

0

131

2

password authentication was removed

0

223

2

section3부터 맥북에서 화면이 안나옵니다.

0

207

2

Git bash 우클릭 보이지 않음

0

350

1

원격 저장소 조회(추가)

0

172

1

혹시 아래처럼 계속 파일을 찾을 수 없다는 건 어떤 의미일까요..

0

137

1

Git 맥북 다운로드

0

293

2

Git bash 다 마우스 우클릭해도 보이지 않습니다

0

414

2

pr 이후 브랜치 삭제 질문드립니다

0

953

2

블로그

0

255

2

github에서 push오류

0

261

1

reset에서 head

0

333

1

git branch 관련 질문

0

217

1

Section 2 / 4강 / 3:23초 질문

0

166

1

diff & revert

0

267

1

이슈 번호를 잘못 명시한 커밋을 삭제하는 방법

0

1179

1

강의 "로컬과 원격의 상호작용 실습 (+충돌이 난 경우)" 편의 영상 7분 38초 쯤에서 질문 드립니다.

0

416

1

mac사용

0

304

1

원격 branch를 checkout 하면서 새 branch를 만드는 방법

0

442

1

git checkout 과 git switch/restore

0

2424

1

로컬 브랜치 관련 질문합니다.

0

199

3

git stash, git tag 에 대한 강의자료가 있으면 좋겠습니다

0

301

1

브랜치를 main(master) 와 동기화 하고 싶을 때

0

9149

1