"Git" creates a new local repository and uploads code (collation)

Source: Internet
Author: User

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#

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.