The setup of GIT environment under Windows environment

Source: Internet
Author: User
Tags using git

The book looked for some time, it is time to start to maintain their personal data. The so-called 工欲善其事 its prerequisite, the development begins with the environment to build first. The environment is built first from your GitHub account.

First of all, any git beginner should first look at the Liaoche Teacher's tutorial, This is very important!!!

1. Go to the official website to download a git for Windows installation package, the installation is complete.

2. Start Menu open git Base, set your username and email

" Your Name "  "[email protected]"

3. Create your SSH key, which appears under my System User folder after success. SSH folder with two files in it

Ssh-keygen " [email protected] "

Now click on the icon in the top right corner after landing from your GitHub account to enter user settings->ssh and GPG keys->new SSH key settings. Title casually fill in, the following the id_rsa.pub just generated with Notepad open to paste the content into, submit. After completion:

4. Create a code warehouse that is associated with GitHub. Here I'm going to create a project called Webdemo under D:/workspace and enter it in Git base

CD d:/CD workspace

Then create a warehouse in GitHub called Webdemo, remember to put it here √, this will initialize a readme.md

Now the local repository clones the remote repository on GitHub, the first time to verify the RSA authentication, enter Yes, and then locally appear the Webdemo folder with the Readme.md file.

$ git clone [email protected]:graywind33/webdemo.git

5. Try using git push to submit your changes

Now I add a test.txt under the folder and enter it in Git base

$ git add-A
$ git commit-m ' add test.txt '
$ GIT push origin master

The first line adds the file, the second line is the Add modification description, and the third line uploads the file to the remote repository.

Here is the direct upload file to the remote repository of the master branch, must be SSH key in the account settings in the local repository to upload, otherwise there is no permission.

You can see that GitHub's code repository already has one more file.

6. Create a new branch and merge

The submission here is a direct upload of the code to cover the main branch, with the problem is that GitHub only play the role of saving code, does not play a role in management. In reality, I may need to temporarily submit code that is not fully completed, or I am not sure if the development part is correct, and if this part is merged directly, my main branch will not function properly, and it is more inconvenient to version management. In terms of work development, I need to make sure that the main branch is available for production release, and that I should have multiple versions of the development version, St Beta version, and so on. These different versions can be thought of as branches. When I confirm that the current project is sufficient to deliver, I then merge the latest branch into the main branch for publishing. On the other hand, if I want to initiate or participate in a multi-person project, obviously I can't put Master's permissions to everyone, only administrators can directly manage the main branch is correct.

Now I create a new branch dev and switch to that branch. With Git branch You can view all the branches, and you can switch to that branch by using git checkout branch name.

$ git checkout-b dev

Now as a test, I'm going to delete the test.txt and then commit the changes to the Dev branch.

$ git add-'Add new Branch,and delete test.txt'$ git push origin dev

Now there's a new branch on GitHub.

Try to switch to the Dev branch and discover that the test.txt is gone and that the master branch still exists.

Now launch a new pull request from the Dev branch and enter some instructions, then click on Create pull request.

Now the administrator is my account can see pull request, I choose to merge after the master branch of the Test.txt file is deleted, two branches merge completed. Of course, I found that the development part of the problem is too great to start over, I naturally will not merge, from the main branch to create a new branch from the new development and submit.

To summarize, we now learn how to install and build a git repository from scratch, and how to create a new branch, commit a modification, initiate a merge request, merge code. The rest of the version fallback, conflict resolution and other issues will be added next time. Now it's time to start a new code tour!

The setup of GIT environment under Windows environment

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.