상세 컨텐츠

본문 제목

##Github 초보의 초기설정과 처음으로 커밋해보기// 에러해결

github

by 담디비 2020. 8. 15. 14:59

본문

안드로이드로 앱 만든게 있어서 github 에 커밋을 해볼라구 

구글을 뒤적뒤적! 

 

먼저 (로컬저장소 이름 ==EX)android)

mkdir android //로컬 저장소 생성 

cd android // android 라는 로컬저장소로 이동 

git init //깃과 로컬 연동! 

 

git add "android App" //내앱파일을 인덱스 (임시저장소)에 추가! 

git commit -m "android App" //인덱스에서 가져와서 커밋해버리기 

 

**** git status 라는 명령어로 git의 추가된 파일들 확인가능 

 

 

>> 다음으로 저장할 원경저장소 (자신의 git주소)를 지정! 

git remote add origin https://github.com/username/repositoryname

그다음 PUSH(파일을 원격저장소로 밀어주기)해주기

git push origin master 

 

**하지만 이런 에러가 발생시는 대부분이 처음에 READ.ME 파일을 만들어서 그럼 

error: failed to push some refs to  https://github.com/username/repositoryname

hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

 

>>해결방법

pull로 모아준다음 다시 push 해주면 된대서 해봄git pull origin masterBUT  fatal: refusing to merge unrelated histories 라는 에러 또발생다시구글링으로 방법을 찾음! git pull origin master --allow-unrelated-histories(--allow-unrelated-histories) = 관련없는 프로젝트 두개의 기록(history)을 묶어주는데 사용한다고함그다음 git push origin master 을 하니 제대로 push 가 작동 ! 튼 여자저차 커밋 성공! HOO