2016-10-22 232 views
0

我想提交到從GitHub克隆的本地存儲庫。我收到以下錯誤消息無法提交到克隆存儲庫

fatal: update_ref for ref 'HEAD': cannot lock ref 'HEAD': ref 
refs/heads/master is at 2b459....[LOTS OF NUMBERS AND CHARACTERS]... 
but expected 000000000000000000000000000 

的git的文件夾的結構如下所示:

enter image description here

輸出git status

warning: refname 'HEAD' is ambiguous. 
warning: refname 'HEAD' is ambiguous. 
On branch master 
Your branch is up-to-date with 'origin/master'. 
Changes to be committed: 
    (use "git reset HEAD <file>..." to unstage) 

    new file: src/actions/types.js 
    new file: src/components/auth/require_auth.js 
    new file: src/components/auth/signin.js 
    new file: src/components/auth/signout.js 
    new file: src/components/auth/signup.js 
    new file: src/components/feature.js 
    new file: src/components/header.js 
    new file: src/components/welcome.js 
    new file: src/reducers/auth_reducer.js 
    new file: style/react-bootstrap-table-all.min.css 

git log --all --oneline --decorate --graph出來放:

* 1d2e02d (HEAD) First working version 
* 2b459d6 (HEAD -> master, origin/master, origin/HEAD) Create .babelrc 
* a7b92d5 Merge branch 'master' of github.com:StephenGrider/ReduxSimpleStarter 
|\ 
| * 29ebda4 Merge pull request #8 from megadix/master 
| |\ 
| | * 7a74747 Filter out IntelliJ IDEA project files in .gitignore 
| * | decca90 Merge pull request #10 from dkarter/master 
| |\ \ 
| | * | 94692d5 Use destructuring to import Component 
| | |/ 
| * | ff4d48c Merge pull request #24 from tsurupin/add-global-navigator 
| |\ \ 
| | * | d976e01 Add global navigator setting to modify the error, 'navigator is not defined', in testing with react-router link 
| * | | b198de2 Merge pull request #29 from hex13/master 
| |\ \ \ 
| | |// 
| |/| | 
| | * | 6246c47 fix typo in README.md 
| |// 
* | | c62b60e moved babel config to webpack 
|// 
* | 2eba18e (tag: 1.1.0) added reactrouter 
* | 3ea279e Update package.json 
* | 78c0fed tweak mocha test command for windows users 
|/ 
* 3f36bba added test boilerplate and helpers 
* 3441a8e Update README.md 
* 92d5200 absolute script and css paths 
* 81cee14 move history fallback to webpack server config 
* 2cd850b using history fallback 
* 31208bf Update README.md 
* c5ad6ad Update README.md 
* 0c7231d Update README.md 
* 6aedde6 fix npm start on windows machines 
* ec41961 Create README.md 
* 7afaf3a added google maps by default 
* 0736160 add lodash 
* f6a7716 use store with middleware 
* 14813f8 middleware setup included by default 
* 1b82228 (tag: 1.0.0) Merge branch 'master' of github.com:StephenGrider/ReduxSimpleStarter 
|\ 
| * fe018bf add default reducer 
* | 3aa34af added css 
|/ 
* e4c4496 state-1 -> stage-1 
* 4709b14 added babel preset 
* 05173d9 used class container as root node 
* 148f186 added bootstrap 
* 9128a89 code cleanup 
* dd358d4 reorder imports 
* 3f0e441 update default text 
* 9eff420 action and reducer setup 
* 246b131 added redux 
* f71dda3 add react redux and redux 
* 544ddfd update repository field 
* dedb285 update package.json 
* dff784d initial commit 
01從 git branch --all

HEAD 
* master 
    remotes/origin/HEAD -> origin/master 
    remotes/origin/master 

輸出

我能夠運行git branch -D HEAD

輸出之後提交現在的樣子:

git status

On branch master 
Your branch is ahead of 'origin/master' by 1 commit. 
    (use "git push" to publish your local commits) 
nothing to commit, working directory clean 

git log --all --oneline --decorate --graph

* 8a21399 (HEAD -> master) First working version (from git-gui) 
* 2b459d6 (origin/master, origin/HEAD) Create .babelrc 
* a7b92d5 Merge branch 'master' of github.com:StephenGrider/ReduxSimpleStarter 
|\ 
| * 29ebda4 Merge pull request #8 from megadix/master 
| |\ 
| | * 7a74747 Filter out IntelliJ IDEA project files in .gitignore 
| * | decca90 Merge pull request #10 from dkarter/master 
| |\ \ 
| | * | 94692d5 Use destructuring to import Component 
| | |/ 
| * | ff4d48c Merge pull request #24 from tsurupin/add-global-navigator 
| |\ \ 
| | * | d976e01 Add global navigator setting to modify the error, 'navigator is not defined', in testing with react-router link 
| * | | b198de2 Merge pull request #29 from hex13/master 
| |\ \ \ 
| | |// 
| |/| | 
| | * | 6246c47 fix typo in README.md 
| |// 
* | | c62b60e moved babel config to webpack 
|// 
* | 2eba18e (tag: 1.1.0) added reactrouter 
* | 3ea279e Update package.json 
* | 78c0fed tweak mocha test command for windows users 
|/ 
* 3f36bba added test boilerplate and helpers 
* 3441a8e Update README.md 
* 92d5200 absolute script and css paths 
* 81cee14 move history fallback to webpack server config 
* 2cd850b using history fallback 
* 31208bf Update README.md 
* c5ad6ad Update README.md 
* 0c7231d Update README.md 
* 6aedde6 fix npm start on windows machines 
* ec41961 Create README.md 
* 7afaf3a added google maps by default 
* 0736160 add lodash 
* f6a7716 use store with middleware 
* 14813f8 middleware setup included by default 
* 1b82228 (tag: 1.0.0) Merge branch 'master' of github.com:StephenGrider/ReduxSimpleStarter 
|\ 
| * fe018bf add default reducer 
* | 3aa34af added css 
|/ 
* e4c4496 state-1 -> stage-1 
* 4709b14 added babel preset 
* 05173d9 used class container as root node 
* 148f186 added bootstrap 
* 9128a89 code cleanup 
* dd358d4 reorder imports 
* 3f0e441 update default text 
* 9eff420 action and reducer setup 
* 246b131 added redux 
* f71dda3 add react redux and redux 
* 544ddfd update repository field 
* dedb285 update package.json 
* dff784d initial commit 

git branch --all

* master 
    remotes/origin/HEAD -> origin/master 
    remotes/origin/master 

Git版本2.7.4,我運行Ubuntu 16.04

我該如何解決這個問題?

+0

'git status'和'git log --all --oneline --decorate --graph'的輸出是什麼? –

+0

您選擇的平臺,git版本和底層文件系統可能是相關的。 –

+1

'git branch --all'的輸出是什麼? – rlee827

回答

1

該錯誤是因爲存儲庫有一個名爲HEAD的分支。由於HEAD跟蹤當前工作的承諾,Git會爲分支命名爲HEAD和git的內部指針當前的工作承諾之間的混淆(因此warning: refname 'HEAD' is ambiguous消息。)

你可以嘗試git branch -D HEAD(正常的方式來刪除一個分支) ,但我不確定這是否會混淆git甚至更多。