Chapter II-The second question (each person builds a HelloWorld project and exercises basic commands like Git's add/commit/push/pull/fetch/clone. Compare the differences between the old and new versions of the project. )--by Hou Weiting

Source: Internet
Author: User
Tags diff

The second question: Each person builds a HelloWorld Project, practice using basic commands such as Git's add/commit/push/pull/fetch/clone. Compare the differences between the old and new versions of the project.

Below I will record my own practice results and personal feelings as follows:

First step: Install Git, set your own account and mailbox, see git Tutorials - Liaoche's official website, which is shown in reference 1 below .

 

 

Step Two : In Git creates a new repository, called HelloWorld, and initializes it.

 

step three: in helloworld New in the repository. helloworld.txt file to practice Span style= "Font-family:verdana;" >git add commit , status diff command.

First Add the helloWorld.txt file to the HelloWorld Library, use the add command, and then The hellowolrd file is submitted to the repository using the commit command, which also uses the git status command to display the current state of the repository To tell the user which files were not added and submitted to the Repository, the results of the commands are shown below.

 

after using the commit command, when you view the current state of the repository, you can see that there are no files that need to be committed to the repository, and use the cat command to view the contents of the current file.

 

 Now I add a new line to the HelloWorld.txt file with the content "test git status and git diff. " And view the current status of the repository and the new and previous versions of the two files, the results are as follows.

 

The add and commit commands are then followed .

Fourth step: in Create a new HelloWorld project in Github and have Git add a Hello Remote library for the practice of push,pull, andfetch commands.

 

in the HelloWorld Project main interface, you can also see the prompt, using git remote add originhw https://github.com/hhhouwt/HelloWorld.git command to connect the local HelloWorld repository with the remote repository. All content from the local repository is then pushed to the remote library HelloWorld using the push command .

at this point, to view the contents of the files in the HelloWorld project in GitHub, we know that the push has been successful, two items have been successfully connected and can be pushed synchronously at any time.

next in GitHub, add another line to the project file HelloWorld.txt, with the content "test pull." and save the commit. Use the pull command on the git side to update the file to the latest version.

 

 

using the same policy, add "test Fetch." To the last line of the HelloWorld.txt file and use the FETCH command to update the file to the latest version.

 

after executing the git fetch command, the view helloWorld.txt can be seen and not updated.

 

so I use the git status command to view the current status, showing that our branch is behind the remote repository, showing that the remote warehouse has been submitted once, but we are still in the state before the commit, we need to use the pull command to update, and finally update the repository to see the contents of the file again. is already the latest version.

Fifth Step: Create a new project Clone_test, and use the Clone command to clone the project.

 

Using the git clone https://github.com/hhhouwt/clone_test.git command in git to clone the contents of the remote library to the local repository, the command displays the following results.

 

after the practice of these commands, the greatest feeling is really very convenient, especially for multi-person cooperation projects, in the past our version of the update is a time and again the mutual transfer of files, the final document after each person modified the final version of the people do not know in who hands, Updates often occur when someone is not updated, so the use of this is really to let us in the version conflict reduced a lot of effort, after the development should also be used in Git.

Resources:

http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000

Chapter II-The second question (each person builds a HelloWorld project and exercises basic commands like Git's add/commit/push/pull/fetch/clone. Compare the differences between the old and new versions of the project. )--by Hou Weiting

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.