As a just entered the workplace before long the front of the small white, really is too embarrassed! In the process of submitting code to git repository, due to unknown reasons, I overwrote others’ code when submitting the code, which was very embarrassing. I had to work overtime with others to restore the code.

However, the problem is so serious that it can also reduce people’s productivity, so I tried to find other tools that can visually submit code, and I found a treasure trove of Sourcetree. Wow, that smells good!!

Wall push!!

Sourcetree basic usage:

A list,

A free Git client for Windows and Mac.

Sourcetree simplifies how you interact with Git repositories so you can concentrate on writing code. Visualize and manage the repository through Sourcetree’s simple Git GUI.

Official website to download address: Sourcetree | Free Git GUI for Mac and Windows

Two, use method:

1. Installation software:

Download and install it directly from the official website. It is a free tool software

https://www.sourcetreeapp.com/
Copy the code

After downloading, you need to log in to SourceTree through an account during the SourceTree installation. However, the registration or login interface may not be opened at all. As a result, the software cannot be installed properly.Solutions:(1) Create file accounts. Json under directory C:\Users{yourname}\AppData\Local\Atlassian. Note: {yourname} needs to be replaced by the login user name. For example, my computer path is: C:\Users\Kelly\AppData\Local\Atlassian.Write the following:

[{"$id": "1"."$type": "SourceTree.Api.Host.Identity.Model.IdentityAccount, SourceTree.Api.Host.Identity"."Authenticate": true."HostInstance": {
      "$id": "2"."$type": "SourceTree.Host.Atlassianaccount.AtlassianAccountInstance, SourceTree.Host.AtlassianAccount"."Host": {
        "$id": "3"."$type": "SourceTree.Host.Atlassianaccount.AtlassianAccountHost, SourceTree.Host.AtlassianAccount"."Id": "atlassian account"
      },
      "BaseUrl": "https://id.atlassian.com/"
    },
    "Credentials": {
      "$id": "4"."$type": "SourceTree.Model.BasicAuthCredentials, SourceTree.Api.Account"."Username": "[email protected]"
    },
    "IsDefault": false}]Copy the code

(2) Restart and enter the page smoothly, as shown in the figure:

2. Pull code

Sourcetree is a free Git client. How to pull code from GitLab? The steps are as follows:

1) Download and install Git

(2) Run git to generate the secret key

The command is ssh-keygen -t rsa, as shown in the figure.

The following figure shows that the public key was generated successfully!

Ssh\ id_rsa.pub in the user directory of your system disk

(3) Bind your own Git public key to your own Git server

Bind: Settings –> SSH Keys –> Add key (open the local public key file and paste all contents inside), as shown in the figure below:

At this point, we directly in Sourcetree click “pull” or “push” code will be the following error, so we need to configure in Sourcetree.

(4) Pull code by sourcetree

Click “Tools –> Options –> General” and pay attention to the Settings of the following four parts, as shown in the picture:Make sure to select Open SSH, ok, and click Push again to implement the push function.You u can see your submissions on GitHub.

(5) Tips: first pull and then push

If a number is displayed on the upper right when pushing, it needs to be pulled before pushing. (If the new code has been submitted by someone else remotely, the “pull” button will indicate that someone else submitted it)

SourceTree&Git

  1. Clone: Create a local repository that is identical to the remote repository by loading it from the remote repository URL

  2. Commit: Upload a temporary file to a local repository (we make changes to the local repository in the Finder usually commit it once before pushing it)

  3. Checkout: Switch between branches

  4. Add: Adds a file to the cache

  5. Remove: Removes a file to the cache

  6. Git Stash: Save your work site

  7. Reset: Returns to the latest Add/commit state

  8. Merge: Merge multiple files with the same name into one file. This file contains all the contents of multiple files with the same name

  9. Fetch: Fetch information from a remote repository and synchronize it to a local repository

  10. Pull: Obtains information from the remote repository, synchronizes it to the local repository, and automatically performs the merge operation, that is, pull= FETCH +merge

  11. Push: Synchronize the local warehouse to the remote warehouse. Generally, pull the local warehouse to ensure consistency before push

  12. Branch: Creates/modifies/deletes branches

  13. Tag: Add a tag to an item

  14. Git Flow: When working in a team, each person creates his or her own branch and submits it to the Master branch

  15. Terminal: Enter the git command line