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