Git + TortoiseGit ultra-detailed configuration steps

Git first opened the account, refer to the previous article

Download git

Download the official website: https://git-scm.com/

Download
Here Insert Picture Description
selection windows
Here Insert Picture Description
to choose your computer version
Here Insert Picture Description
installed git. Double-click to open the "Git-2.14.0.2-64-bit.exe" All default selection, has been click Next to complete the installation

Download the graphical interface management tool

Here Insert Picture Description
Here Insert Picture Description
There are a lot of graphical interface management tool, choose one you like you can, I choose here
TortoiseGit

Here Insert Picture DescriptionClick to download, enter the following interface
Here Insert Picture Description
here to download two packages:
a client installation package is
a language pack

Configuration

1. First, select a project directory Git storage, easy management such as:. D: \ test, then open in Explorer.

2. Right-click in the blank, right-click menu you can see a few more options. Select -> TortoiseGit -> Settings, then you can see the configuration interface.

3. Click on the General simple configuration. Language can switch the language (landlord more accustomed to English). Uncheck the automatic upgrade box. Git.exe may also need to specify the path to the file, such as "D: \ DevlopPrograms \ Git \ bin". When finished, click Apply, OK to close the dialog box. As shown below:
 Here Insert Picture Description
4, arranged context menu .. In the Settings dialog box, click on the left of the "Context Menu", set common right-click menu. The landlord of the more common options are as follows:
Here Insert Picture Description
5 to set a password to remember

!!! passwords are stored in plain text in C: \ Users \ Administrator.git-credentials this file, please use caution.

Enter the setting, click the left Git tags can be found, the user can configure the name of the right and Email information as shown below:
  Here Insert Picture Description
  Since currently no local project, so "Edit local .git / config (L )" button is gray unavailable, if you open the configuration dialog in a local Git project, you can use this button, and then you can edit some of the properties of this project.

Click "Edit global .git / config (O)" button, use Notepad to open the global configuration file in the global configuration file, followed by the following:

[Credential]
Helper = ******* // - Password

After completion of the saving, closing Notepad, can be determined.

 当你推送项目到GitHub等在线仓库时,会记住你输入的用户名和密码

Examples

Cloning a project (the landlord is available on github)

In the working directory, such as D: \ test, the blank right, select: Git clone, clone dialog box will pop up, as shown in FIG.

Here Insert Picture Description
Fill out the project in the URL address to access, such as: https: //github.com/xuwenjin/xwj-test.git

According to the project size, time will be different. After completion of cloning, if no errors, will prompt:
    Here Insert Picture Description
enter the clone file folder, such as D: \ test \ xwj_repo, blank right, following menu:
Here Insert Picture Description
wherein, Git Pull latest code is pulled from the distal end , Git fetch is pulled from the distal end of the latest branch, Git Push is the local repository code delivery to distal

Git Commit -> "master", will be submitted to the local native code repository (the default branch is master)

Native code will be submitted to the local repository

Create a file, such as test1.txt, then submit (commit) to a local repository (this operation can operate in an offline state)
    Here Insert Picture Description
    Here Insert Picture Description
 2.1 Select Git Commit -> "master", pop up the following figure:
    Here Insert Picture Description
2.2 Fill submit remarks message (do not fill no allow submission), check the documents submitted, click commit, to native code will be submitted to the local repository.

Appear as playing box indicating successful submission
Here Insert Picture Description
wherein, when submitted, will find that there are several values above figure Status:

Unknown: new file, not in the repository

Added: New documents in the repository

Modified: file modification, in the repository

Missing: a file is deleted in the repository

View Log

Right choice Git Show Log (this menu you can configure it through the above said). In the log, by date, file name, author, etc. to filter the query.
Here Insert Picture Description
Through the log, it can be very intuitive to see the submission of relevant records. Such as author, submit time, which submitted a file, and so on. Compare files after the information or facilitate version
rollback (will explain later) Click test1.txt, you can see this submission, on the test1 file operations performed
Here Insert Picture Description
as to how these colors to see what does it mean, you can go to Baidu , will not be discussed

Code push (push) to the distal end. Here is the github

Right-space, select Git Push, bomb box appears as follows:
Here Insert Picture Description
Here you can see which is submitted to the local repository to the remote. At this point, the entire process of document submission is complete

Branch

I found the problem: You write a lot of code, run OK; but suddenly want to add new features into this feature you do not know whether the normal operation, and modify the process, in addition to the newly added code and files in it, but also modify previous code. If the case fails, modify the back is a very troublesome thing. This time a lot of people with a backup. Git is a look at how to deal with this problem elegantly.

Treatment of git: When you want to add a new feature into it, you can create a new branch, such as name newbranch, then branch to the new features add to, if OK, the code is merged into the master branch, if the new function fails, switch back to the master branch up in newbranch write code, I can not see the whole.

5.1 Create a new branch, right -> TortoiseGit-> Create Branch
  Here Insert Picture Description
  right, you will find the current branch to branch of your new newbranch
Here Insert Picture Description
5.2 Next, you will be happy to add features, such as our new file in test1.txt a line of text, while adding a file test2.txt
Here Insert Picture Description
5.3 submit our code to your local repository newbranch branch, reference previous 2.2

5.4 suddenly find this feature loopholes, think back to the master branch before, how to do it?

Right -> TortoiseGit-> Switch / Checkout, you can select the master. Below:
    Here Insert Picture Description
    5.5 blank right, you will find has switched to the master branch. The Discovery test2.txt did not take over, let's look at whether test1.txt file back to the past it?
    Here Insert Picture Description
    The results show that both modify or add, did not affect the files on the master branch, which is the role of the branch.

Branches merge

If at this time discovery on newbranch branch is effective, hoping merged into master, then how does it work?

PS: Before merging branches, be sure to confirm newbranch code on all submitted to the local branch of the repository

Right -> TortoiseGit-> Merge, select the merged branch, namely newbranch. The figure below
    Here Insert Picture Description
    6.1 Click Ok button to play the next chart box appears. Bomb box lists the files to be merged. As shown below:
    Here Insert Picture Description
    6.2 We found test2.txt files are combined over, open the test1 file, find exactly the contents on newbranch branch changes.

At this point, the merger is completed branch

Pull (pull) the distal end of the latest content

At this point, we have another member of the team B, he needs to obtain the contents of my latest changes, how does it work?

First B switch to the same branch with me, then right -> Git Pull, click to confirm, you can modify the contents pulling me to his local repository

Version rollback

8.1 to view the log, want to roll back to determine which version (which knowing why you want to fill in remarks submitted to the bar)
    Here Insert Picture Description
    8.2 for example want to roll back to a previous file before creating test1.txt, then click on the step operation corresponding to the message that a log (add spring demo)

Then right -> Reset "master" to this ..., said it would roll back the file on the current master branch to this version, as shown below
      Here Insert Picture Description
      8.3 after selecting the menu, the following bomb box, select the type of your fallback in Reset Type (General landlord select Hard: Reset working ......), click Ok to
      Here Insert Picture Description
      find, this time test2.txt file disappeared, as shown below:
      Here Insert Picture Description

Resolve conflicts (slightly)

Reference article:
https://www.cnblogs.com/xuwenjin/p/8573603.html

Published 34 original articles · won praise 2 · Views 2315

Guess you like

Origin blog.csdn.net/weixin_44088559/article/details/105241072