Git initialization and customization of the initial directory

Source: Internet
Author: User

Git can say the project version control required tools, from the fiery GitHub know, ask the net also share a lot of good plug-ins git address, you may not know how to use this, this article on git initialization and customization of the initial directory to explain.

Initializing a project

You need to push the code to a remote repository to initialize the empty warehouse on the 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 warehouse is on the push branch (if it is not in the push branch, there is no problem), Then the results of the push will not be reflected on the work tree, that is, in the remote Warehouse directory of the corresponding files or previous content, you must use Git reset–hard to see the push content.

It is best to initialize a remote repository with the following command:

Git--bare init

And do not use:

Git init

Customizing the initial Directory

Every time you open git Bush, the default directory is always Windows personal Folders, and then you have to use the command to go to your work directory, it is very troublesome. Later found a way to customize the initial directory of Git, in fact very simple, right click on the desktop Gitbush, right click on the open properties, change the initial location of the directory for your work directory, save

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.