轉自:http://blog.csdn.net/weihan1314/article/details/8677800html
版權聲明:本文爲博主原創文章,未經博主容許不得轉載。android
git init 和git --bare init 的具體區別參考:http://blog.haohtml.com/archives/12265 web
提示: Initialized empty Git repository in /data/Downloads/Git/android4.2/.git/證實git倉庫(repository)建立成功
remote: error: refusing to update checked out branch: refs/heads/mastervim
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 inconsistentless
remote: error: with what you pushed, and will require 'git reset --hard' to matchui
remote: error: the work tree to HEAD.this
remote: error:spa
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'.
To git@192.168.1.X:/var/git.server/.../web
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'git@192.168.1.X:/var/git.server/.../web'
在代碼倉庫建立一個說明文檔(該文檔能夠隨便建立)
error: src refspec master does not match any.
error: failed to push some refs to '/data/Downloads/Git/android4.2/.git
所以咱們須要在初始化代碼倉庫以後,在倉庫中建立一個文件:
實例:
建立myprojects目錄,同步代碼
使用git diff 和 git status 命令能夠查看代碼當前的狀態
提交代碼
查看代碼倉庫中代碼是否提交成功
進入代碼倉庫目錄,查看代碼提交log
若是使用了git init初始化,則遠程倉庫的目錄下,也包含work tree,當本地倉庫向遠程倉庫push時, 若是遠程倉庫正在push的分支上(若是當時不在push的分支,就沒有問題), 那麼push後的結果不會反應在work tree上, 也即在遠程倉庫的目錄下對應的文件仍是以前的內容。
使用如下命令便可查看提交的內容
$git reset --hard
回退到當前最新(本地最新)提交的代碼信息