Nice programing

Git으로 파일 이름 바꾸기

nicepro 2020. 11. 6. 20:03
반응형

Git으로 파일 이름 바꾸기


저는 Git / Github를 처음 사용하며 도움이 필요합니다. README에서 README.md로 파일 이름을 바꾸고 싶습니다. "change-z-index"라는 저장소가 하나뿐입니다.

1) 다음과 같이 열고 로그인합니다.

ssh -T git@github.com

그리고 내 암호를 입력합니다.

2) 다음과 같이 파일 이름을 바꾸려고합니다.

git mv README README.md
git commit -m "renamed"
git push origin master

잘못된 소스 라는 오류가 발생 합니다.

먼저 내 저장소를 선택해야한다고 생각합니다. 이름은 "change-z-index"입니다. 설명서를 여러 번 읽었지만 여전히 사용법을 이해할 수 없습니다.


내가 알 수있는 한 GitHub는 셸 액세스를 제공하지 않으므로 처음에 로그인 한 방법이 궁금합니다.

$ ssh -T git@github.com
Hi username! You've successfully authenticated, but GitHub does not provide
shell access.

리포지토리를 로컬로 복제하고 거기에서 변경 한 다음 변경 사항을 GitHub에 푸시해야합니다.

$ git clone git@github.com:username/reponame.git
$ cd reponame
$ git mv README README.md
$ git commit -m "renamed"
$ git push origin master

2013 년 3 월 15 일 부터 GitHub에서 직접 파일을 이동하거나 이름을 바꿀있습니다 .

(당신도 REPO 그, 복제 할 필요가 없습니다 git mv xxgit push다시 GitHub의에!)

이름 바꾸기

파일 이름 필드 만 사용하여 완전히 새로운 위치로 파일을 이동할 수도 있습니다.
폴더로 이동하려면 파일을 이동할 폴더의 이름을 입력 한 후 /.
폴더는 이미 리포지토리의 일부인 폴더 일 수도 있고 아직 존재하지 않는 새로운 폴더 일 수도 있습니다!

움직이는


gitmv명령을 사용하여 파일 이름을 바꿀 수 있습니다 .

$ git mv file_from file_to

예:

$ git mv helo.txt hello.txt

$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   renamed:    helo.txt -> hello.txt
#

$ git commit -m "renamed helo.txt to hello.txt"
[master 14c8c4f] renamed helo.txt to hello.txt
 1 files changed, 0 insertions(+), 0 deletions(-)
 rename helo.txt => hello.txt (100%)

튜토리얼을 진행하면서 비슷한 문제가 발생했습니다.

# git mv README README.markdown

치명적 : 잘못된 소스, 소스 = README, 대상 = README.markdown

소스 파일에 파일 형식을 포함했습니다.

# git mv README.rdoc README.markdown

완벽하게 작동했습니다. 다음과 같이 변경 사항을 커밋하는 것을 잊지 마십시오.

# git commit -a -m "Improved the README"

때때로 그것은 우리를 화나게하는 그런 단순한 작은 것들입니다. LOL


Do a git status to find out if your file is actually in your index or the commit.

It is easy as a beginner to misunderstand the index/staging area.

I view it as a 'progress pinboard'. I therefore have to add the file to the pinboard before I can commit it (i.e. a copy of the complete pinboard), I have to update the pinboard when required, and I also have to deliberately remove files from it when I've finished with them - simply creating, editing or deleting a file doesn't affect the pinboard. It's like 'storyboarding'.

Edit: As others noted, You should do the edits locally and then push the updated repo, rather than attempt to edit directly on github.


예를 들어 현재 디렉토리에없는 README 파일을 호출하는 것과 같이 대상 파일이 찾을 수 없거나 존재하지 않기 때문에 "Bad Status"가 있습니다.

참고 URL : https://stackoverflow.com/questions/6889119/rename-file-with-git

반응형