(turn) about git warehouse initialization and GIT push action

Source: Internet
Author: User
Git initialization 2010-08-26 16:53

**********************************************************
Install a remote repository for git 2010-05-28 Linux View Comments

Need to push code to a remote repository

Initializing an empty warehouse on a remote server

Mkdir/home/git/myapp.git && Cd/home/git/myapp.git
Git–bare Init
Initialization of an empty warehouse

Add a remote repository at the local git warehouse
CD ~/myapp
Git remote add Origin ssh://myserver.com/home/git/myapp.git
At this time, the local. Git/config should change.

Git push Origin Master
To track a local master branch to a remote branch

displaying remote information
git remote show origin
**********************************************************

git rejects the push operation by default and needs to be set up and modified. Git/config Add the following code:

[Receive]
Denycurrentbranch = Ignore

It is best to use git--bare init when initializing remote warehouses instead of: Git init

   If you use git init initialization, the Remote warehouse directory also contains work tree, when the local warehouse is pushed to the remote warehouse,   If the remote repository is on a push branch (if it is not a problem at the time of the push branch, then the result of the push does not reflect on the work tree, , which is the corresponding file or previous content in the remote repository directory, must use git reset- Hard can see the content after the push.
*********************************************************

The best use of the following command to initialize the remote repository:
git--bare init
instead of:
git init

If you use git init initialization, the Remote warehouse directory also contains work tree, when the local warehouse is pushed to the remote warehouse
If the remote repository is on a push branch (if it is not in P Ush Branch, there is no problem)
Then the result of the push will not be reflected on work tree
also in the Remote Warehouse directory
corresponding files or previous content, you must use git reset--hard to see the content of the push

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.