I wrote an article about http://blog.csdn.net/commshare/article/details/20526369 before.
The feeling is still not clear, so today again tried several times, summed up as follows:
1. Build the remote warehouse first
Distal:
Git--bare init
It's OK.
Attention
after joining the--bare, don't add a new file directly to the Git directory, and don't push it.
Otherwise there will be an error:
Fatal:this operation must is run in a work tree
This is caused by the addition of--bare.
====
git--bare init
after that, you can see the warehouse in the Gitweb.
2. Upload the local code to the remote
(1) Git init
(2) Git remote add Origin file:///local warehouse path
(3) Add a new file
(4) Push Origin master is good.
And then it's OK.
========================================
My process is as follows:
root@ubuntu32:/home/zhangbin/stm/platinum/myui# ls
Chrishaseman-chapter-2-aaeaa28
root@ubuntu32:/home/zhangbin/stm/platinum/myui# git init
Initialized empty Git repository in/home/zhangbin/stm/platinum/myui/.git/
root@ubuntu32:/home/zhangbin/stm/platinum/myui# git remote add Origin file:///home/zhangbin/alex/gitProject/meUI.git
root@ubuntu32:/home/zhangbin/stm/platinum/myui# git pull Origin Master
FATAL:COULDN ' t find remote ref Master
Fatal:the remote end hung up unexpectedly
root@ubuntu32:/home/zhangbin/stm/platinum/myui# ls
Chrishaseman-chapter-2-aaeaa28
root@ubuntu32:/home/zhangbin/stm/platinum/myui# Touch the README. Md
root@ubuntu32:/home/zhangbin/stm/platinum/myui# git add README. Md
root@ubuntu32:/home/zhangbin/stm/platinum/myui# git push Origin master
ERROR:SRC Refspec Master does not the match any.
Error:failed to push some refs to ' file:///home/zhangbin/alex/gitProject/meUI.git '
root@ubuntu32:/home/zhangbin/stm/platinum/myui# git commit-m "initial commit"
[Master (Root-commit) 3e5f447] Initial Commit
1 file changed, 0 insertions (+), 0 deletions (-)
Create Mode 100644 README. Md
root@ubuntu32:/home/zhangbin/stm/platinum/myui# git push Origin master
Counting Objects:3, done.
Writing objects:100% (3/3), 215 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (Delta 0)
To File:///home/zhangbin/alex/gitProject/meUI.git
* [New branch] Master-> Master
root@ubuntu32:/home/zhangbin/stm/platinum/myui#