Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

git 사용하면서 발생하는 문제들의 해결 방안 모음 ( git tips  문서도 참고)

Panel
titleBGColorgray
titlegit 사용중 발생하는 에러 유형 및 처리 모음

 

Table of Contents

Children Display

 

Git Tips

...

git

...

svn add 후에 잘못 add 한 파일을 revert 하는 것처럼 git 에서도 add 한 것을 revert 하는 방법

git reset HEAD <file>

hello.java 를 잘못 추가했다면 git reset HEAD hello.java 를 실행

22번 이 아닌 다른 SSH 포트 사용하기

git + ssh 연계시 22 번 포트가 아닌 다른 포트 사용할 경우 앞에 ssh:// 를 적고 id@host:포트번호를 적어줌

Code Block
git clone ssh://lesstif@mydomain.com:[port]/var/lib/git/myproj.git
Note

포트 번호를 적지 않을 경우 host 명과 path 사이에 : 가 없어야 함. (: 가 있으면 : 를 포함해서 host name 으로 인식해서 "mydomain.com: no address associated with name" 에러가 발생함

git clone ssh://lesstif@mydomain.com:/var/lib/git/myproj.git

 

 

여러 개의 remote repository 설정하기

svn 은 하나의 repository 만 설정할 수 있지만 git 은 여러개의 repository 를 설정할 수 있다.

Code Block
languagebash
git remote add alt alt-machine:/path/to/repo

모든 remote 에서 branch 및 update 된 내역을 가져오려면 다음 명령어 실행(HEAD 에 merge 하지는 않는다.)

Code Block
git remote update

alt remote 의 master branch 에서 fetch 하고 현재 HEAD 에 pull

Code Block
git pull alt master

...

push

...

TroubleShooting

 

...

시 "No refs in common and none specified; doing nothing. Perhaps you should specify a branch such as 'master'."

Code Block
git push origin master


Git push error '[remote rejected] master -> master (branch is currently checked out)'

Code Block
Counting objects: 13, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (13/13), 2.89 KiB | 0 bytes/s, done.
Total 13 (delta 3), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsist
ent
remote: error: with what you pushed, and will require 'git reset --hard' to matc
h
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.

...

 

Git push: fatal: The current branch master has multiple upstream branches, refusing to push

git config remote.origin.push HEAD

Git pull: You asked me to pull without telling me which branch you want to merge with, and 'branch.master.merge' in your configuration file does not tell me, either.

Expand
titleError Message - Click here to expand...
Panel

 * [new branch] master -> origin/master

You asked me to pull without telling me which branch you
want to merge with, and 'branch.master.merge' in
your configuration file does not tell me, either. Please
specify which branch you want to use on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details.

If you often merge with the same branch, you may want to
use something like the following in your configuration file:

[branch "master"]
remote = <nickname>
merge = <remote-ref>

[remote "<nickname>"]
url = <url>
fetch = <refspec>

See git-config(1) for details.

...