Use Sublimegit plug-in in sublime Text3

Source: Internet
Author: User
Tags diff install django sublime text virtual environment django tutorial

Similar reference: https://segmentfault.com/a/1190000007200311 Tutorial

This tutorial describes the usual stages of using sublimegit to manage projects. We'll build the Django Tutorial application and manage it with git. We will gently skip the coding section and focus on using sublimegit, so it should be available for any project that uses Git. Set up

The first thing we do is to do a virtual environment, set up a require.txt, install Django and initialize a Django project. This means that our project folder now looks like this:

initializing the repository

Now, this project doesn't have much work to save, but we're going to start adding some, so it's probably a good time to put the project in Git.

To do this, first make sure that you open the project in sublime text. It does not need to be opened as a sublime text item, personally I prefer to open the folder directly from the command line, or through the file> open ... Menu.

Attention

Notice how we open the entire folder in sublime text. This is not required, but it will make git warehouse initialization smoother because Sublimegit will have an easier time figuring out where to place it.

For more information on how Sublimegit chooses the repurchase path, see: Ref: ' Git:init <cmd-git-init> ' command.

To initialize the Git repository, open the Command palette and locate the Git:init command. But wait a minute. You do not want to enter the full command name for all content. Luckily, Sublime text is very smart for matching commands, so to find the Git:init command, we should be able to start typing. Typically, all the commands in Sublimegit start with git: prefix, so let's try typing ginit.

Once we enter Gin,sublime text should have selected the correct command. Now press ENTER, and you will see the repository where you choose to place at the bottom of the screen:

If you open our project as a folder, the default value should be sufficient and you can press ENTER to select it. After you create the Git repository, Sublimegit displays the output of the GIT command in the console window:

To close this console window, press escape.

Attention

Another way to initialize the repository is to start using the Git:status command. If you are not in the repository, Sublimegit will ask you to initialize one. Add Content

So now that we have an empty database, we can start adding our files.

Warning

Using Sublimegit to perform initial submissions on a large project (1000+ file) may not be the best way to do it. Get a list of the files that are not tracked from Git, and it may take some time to format them.

If you are working on a huge project, you may want to use the command line for initial submission. Status View

Most of the additions/segments/segments and so on are from: Ref: ' git:status <cmd-git-status> ' command, so let's run it. GS typing in the command palette should be sufficient to make it work:

After the command is executed, we will see a view of the status, as follows:

This view contains the following information about our new project: Local information about our current branch (main) and the location of our repository (〜/desktop/djangotut) header information about the current head submission. Since we haven't done anything yet, there's nothing to show for it. After our first submission, we will be able to see the initials SHA1 and the first line of the submission message. Unencrypted files This section shows the files in our project that have not been added to git. When we learn more, there are more sections, such as unchanged changes, segmented changes, and shadowing. Help me. Displays the available keyboard shortcuts at the bottom of the view. Ignore file

Now look at our status View, we notice we've got these troublesome. pyc files. We definitely don't want to add them to git, so let's ignore them.

Press the I file to add the file to the. Gitignore Repository. But we don't want to add only one. pyc file, we want to add mode *. PYC, so we don't have to deal with them anymore. Press I (capital I) will give you the option to add to the Gitignore mode:

Now, we change the pattern to *. PYC:

Pressing ENTER will require you to confirm your selection, and after doing so, we can see that the. pyc file has been removed from the status View and the Gitignore file has been added:

Add Files

Now, to add files, there are several different ways you can go.

We can individually press each file and allow the status window to be updated each time it is pressed. If we don't want to wait for the status window to update, we can also select all the files we want to add, and then press S. Alternatively, we can use the sublime text's awesome multiple caret feature and insert the symbol s on each line before pressing. This will add all the files because Sublimegit supports multiple selections.

Another way is to place the caret in the section heading and press S.

Finally, we can press Ctrl+shift+s this will add everything. This command can lead to a lot of changes, which is why it is purposefully being made some difficult typing.

Let's put the cursor over the section and press S:

To move a file to the segment change section by s file:

Now we are ready to make an initial commitment to our project. other ways to add files

Using the Status view is not the only way to add a file in Sublimegit. See also: Ref: ' Cmd-added-files ' in: Doc: ' Commands ' in substitution. Submit

To enter the submit view, please press C in the status View. This will enter the submit information for you and place the caret so that you can start typing immediately:

Attention

This view contains a 72-character vertical ruler. This is to encourage good letter styles, as detailed in Tim Pope and Linus Thorvalds.

If you write down such submissions, other developers will quietly nod their heads, and 1000 of cute kittens will be saved and wealth will fall from the sky. In addition, you will get a good git log and provide good news on the GitHub.

So we enter our submission information:

When you finish typing, closing the view will execute the submission and notify us in the Control Panel:

We can now see that our header information has been updated and the working directory is clean. Suspension of Commitment

What to do if we change our mind by writing the submission information. At this point, closing the file will commit the half completed submission. The solution is simple. Just delete the submit message. This can be done by selecting all content (Cmd+a on OS X, CTRL + A on Linux/windows), followed by delete.

Closing the null submit view aborts the submission and notifies you that:

Phased Change

So now that we've done our initial submission, let's make some changes to the project.

After you change the settings and add the polling application, the status view now looks like this:

Since we actually do two separate things here, we might want to divide it into two submissions, one containing changes to settings.py, and the other containing our initial voting application.

But first, let's take a look at what we actually changed. View Differences

Navigate to the Change section. A quick way is to press 2 to jump to part two, followed by n next item. Another way is to press a section of NN and then press a file.

Once the caret is over the file, press D to open the diff view:

We can see here that we have changed the database settings, the time zone, and enabled the admin application.

As we look at this discrepancy, we realize that we might also need to add a template directory. So let's close the diff view and open the file to add the template directory. Open File

Back in the status view, the caret should still be in the settings file. Press ENTER to open the file for editing:

After adding the missing settings, we can view the diff again to see that the changes have been selected:

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.