This is the first day of my participation in the Gwen Challenge in November. Check out the details: the last Gwen Challenge in 2021

preface

When we are familiar with Git’s submission and branch, we can be more efficient by using GUI tools after skillfully operating Git with commands. Git has many graphical interface tools, such as the classic Little Turtle.

Today we are going to talk about SourceTree briefly, which is also a good choice!

First download the SourceTree installation from the official website and run it directly.

Configuring SSH Keys

First of all, if you don’t have a key, just create a new one.

Go to Tools –> Options

General option Settings

Add the warehouse

Adding a Local Folder

If you don’t have a git repository for the first time, you can add a local git repository by adding folders to it.

Clone remote repository

Here we click on the Clone option, enter the location of the repository to Clone, and wait for the Clone to succeed.

Success will bring you to the main screen

Click History to view the commit record for the repository. At the same time, we opened the path to our local repository and found that we already had a.git folder and a new readme.md file

submit

Let’s make changes to the file before committing to the test.

When we click on the file status, it will detect that the file has been changed. The submit button in the upper left corner also has a number showing how many files have been changed. Because we are working in a local copy, we commit to the local repository first, and then push to the remote repository.

To submit, we start with the first step, temporary file

There are three temporary storage options

  1. Temporary storage: Temporary storage of all files at one time
  2. Temporary Selected: Only the files you selected are temporarily saved
  3. The plus sign (+) at the end of the file: saves the current file temporarily

After temporary storage, it will appear in the above temporary file location, there is also an operation to cancel temporary storage

We hit Submit and then push

Commit. After the successful commit, you can see that a new one has been committed in history, but only to the local repository, not the remote repository

At this point, the github file remains unchanged

We can see that the push has a number 1, so we select the push code and wait for the push to succeed

After the push was successful, we can see that there are two more remote branches in the branch and github has been updated synchronously.

To obtain

Now that we’ve looked at the commit code, let’s update the file in the remote repository and then pull the code.

Fetching is updating the code from the remote repository to the local repository, and pulling is updating the code from the local repository to the local working copy. Go back to sourceTree and click the Get button

Later we can see that there is a number in both pull and split. The number in the branch indicates that there is an update that needs to be pulled to the local working copy, when the local file is not updated.

Click the pull button

After success, we find that the pull prompt has disappeared and the local file has been updated

branch

When we want to add a new feature, if there is a function that does not break the original code, we add a branch, and then carry out the development of the function. Wait to complete before merging onto the main branch.

Click the branch, print the name, and create will generate a new dev branch

This is our branch created successfully, but there are still local branches. Node is shows the dev, origin/master, origin/HEAD, master. Origin indicates that the remote repository exists

Next, we click push and check the dev branch to push the local dev branch to the remote dev branch

After the push completes, you can see that the local dev and remote dev have been synchronized. Origin /dev is added

Then we added a test function to the dev branch,Select the Dev branch and commit.

After we commit, we can see that the dev branch has one more commit record than the master branch

Dev branch

The master branch

Join us and the reality function is implemented and passed the test. Now, it’s going to merge into the main branch.

Switch the current branch to the Master branch (double click). A small dot in front of the branch indicates that you are in the current branch. Click on the Dev branch (it has a gray background), right-click, and select Merge Develop to the current branch (the main branch).

And I’m gonna say OK

This is where we can see an extra push in the master’s local repository. Icon 2, shown in the red box, indicates that the new test functionality of the dev branch has been merged into the master branch of the local repository.

Push the merge test function, you can see that the master branch also has the new test function

conclusion

Hopefully, you can learn some daily use of SoureceTree from this article, and also learn how to use a tool. Even better, give it a thumbs up, please! Ha ha ha ~