GIT GUI and github use

The company mainly uses SVN for version management. As a developer, I have never used git-related tools. I am ashamed. I have recently learned git, so please advise me.

1. Create a new local repository

First, we open the Git GUI is such an interface, select the first item, create a new repository. 
Write a picture description here 
Then select the project path where you need to perform version management. I chose a LoginDemo project. 
Write a picture description here 
When you create a repository, you can see an additional .git folder (invisible if hidden files are set)
Write a picture description here
in the project path  in the Git Gui if Unstaged Changes If the file is included, click Stage Changed to add uncached changes to the cache, and then click Commit; otherwise, you need to click Rescan to scan the changed files in the project. Note: The submission description must be filled in, otherwise it cannot be submitted. 
Write a picture description here
After the submission is successful, we can see the history of our submission in Repository-> Visualize All Branches History (this is submitted to the local rather than submitted to the remote server). At this point, the local repository is successfully created. 
Write a picture description here

2. Submit the project to the remote

In the previous step, Git has been used to build a local repository, and then we need to submit the project to a remote server so that colleagues or other collaborators can participate in the development. General open source projects use github as a remote server. In fact, after the local resume version library, just click push to upload directly. However, we have not established a connection between Git and github and set up a security protocol.

First, we need to have our own github account, and then create a new repository on github, the name is also called LoginDemo (it can be different from the local project name). 
Write a picture description here 
In Git Gui, select Remote-> add to add a remote server. There are two ways to fill in the remote server information. Fill in the https address or ssh address, which corresponds to the https and ssh addresses of the github project. It is recommended to use the ssh method.

1. https address

This way you need to enter your github account and password, which means you can only operate your own projects in this way. 
Write a picture description here

2.ssh address

This method requires authorization settings. In the menu bar of Git Gui, click Help-> Show SSH key-> Generate SSH KEY to create a key. 
Write a picture description here 
Then add it in the personal settings of github, the title is arbitrary, you can use Home, company, etc. as the logo to distinguish. 
Write a picture description here
Add remote server information. 
Write a picture description here

Next, we can click push directly in Git Gui to submit to the remote client, refresh github, and we can see that the project is already in the repository. 
Write a picture description here

3. Download updates from remote

Imagine that many people participate in the project development, and everyone only pushes to the remote, regardless of the progress of other members. Such a development model is undoubtedly problematic. Our best practice is to fetch the current progress from the remote first every time you push to the remote. After you merge with your current project progress, then push it to the remote. Open Git Gui, select Remote-> Fetch from-> LoginTest in the menu bar, you can update from the remote server to the local, but have not yet merged with your current project. 
Write a picture description here

4. Merge conflict resolution

After fetching from the remote, select Mit-> Local Merge of Git Gui to merge, and select Tracking Branch. 
Write a picture description here 
If there is a local method named findUser, and the name of the method is changed in the remote server, for example, it becomes findPassword, the merge encounters a conflict, you can right-click the blank part and choose to keep the local version or the remote version to merge (green The code indicates the conflicting part). 
Write a picture description here

5. Clone the project on github to the local

On the main interface of Git Gui, choose to clone an existing repository. 
Write a picture description here 
Source Location is the address of the project in github. As in the second part (submitting the project to the remote), you can choose the https address or ssh address. Target Directory is the path to store the project locally. Click Clone to successfully clone the project from github to the local. 

Write a picture description here

modify by 2018.3.15

Fill in the address of the repository in the Arbitrary Location box in the upload dialog box. You can find this url from the test library on the github site, and copy it. Click the upload button and enter your github username and password in order to complete the upload.

After everything is completed, you can see the file you uploaded on the github site.


Published 15 original articles · praised 3 · 10,000+ views

Guess you like

Origin blog.csdn.net/edward_2017/article/details/79537077