Create a local GIT repository using SOURCETREE

Source: Internet
Author: User
Tags yii sourcetree
You can use git for version management. How can you add a local project to the git version library and use the git command or sourcetree tool for version management?
First, open sourcetree and click "command line mode ". This operation is more convenient in command line mode.
Take the windows environment as an example. For example, if a WEB project is in path D: \ xampp \ htdocs \ yii2, first move the folder to disk D, create an empty yii2 folder in the original directory.
Run the following command to enter the yii2 folder on drive D, for example:
Cd yii2
Use the git init command to create a version library, for example:
Git init

Git init command

In this way, git information is created for the local project folder, but the file has not been submitted to the version Library. (We recommend that you use git-bare init for initialization. For more information, see)
Then point to the git add. Command and git commit to submit the file.
As shown in the following figure:
This is to go to the yii2 folder of drive D and use the git init command to create the git version Library.
This is to use the git status command to view the status of the current version of the database. These files are not submitted and the prompt is: use "git add <file> ..." To include in what will be commiteed.
The next two steps are very important.
Run the git add. Command to add these files to the version library, and then run the git commit-m "add files" command to submit the files.
After the execution, the code is submitted to the newly created git version Library. Then you can use sourcetree or the native git command to manage local projects. For example, clone this project in sourcetree:
In this way, the empty folder D: \ xampp \ htdocs \ yii2 contains the content, and the development is still in this folder in the future. All operations will be recorded in the git version Library.
Supplement:
Open PHPStorm, find a prompt at the bottom, and click the prompt. I performed an operation according to the suggestions, as shown in the figure:
After clicking "Add root", the current directory is used as the root directory, and a. ignore file is automatically generated in the root directory. PHPStorm automatically adds some ignore File items.
The code is as follows: Copy code

. Ignore file content:

# Yii console command
/Yii
 
# Phpstorm project files
. Idea
 
# Netbeans project files
Nbproject
 
# Zend studio for eclipse project files
. Buildpath
. Project
. Settings
 
# Windows thumbnail cache
Thumbs. db
 
# Composer vendor dir
/Vendor
 
# Composer itself is not needed
Composer. phar
 
# Mac DS_Store Files
. DS_Store
 
# Phpunit itself is not needed
Phpunit. phar
# Local phpunit config
/Phpunit. xml

It's so intelligent! Then you can use the Git version comparison tool that comes with PHPStorm. In PHPStorm (version 9.0), there is a show history button in the upper-right corner to open it.

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.