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

 

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

git push origin master


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

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'.

remote repository 를 bare repository 로 만들어야 함.

remote repository 에서 다음 명령어 실행

## repository 로 이동
cd /var/lib/git/myproj.git
git config --bool core.bare true
## 그리고 .git 을 제외하고 remote repository 의 모든 파일 삭제

client 에서 실행

git push

 

 

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.

 Error Message - Click here to expand...

 * [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.

 

.git/config 파일에 다음 내용 추가

[branch "master"] 
remote = origin 
merge = refs/heads/master