[Windows] Github getting started, github getting started

Source: Internet
Author: User
Tags git commands

[Windows] Github getting started, github getting started
I. Summary

Github is an open-source code library and version control system. The better you can use it, the higher quality of engineering and Code on github. You can use fork + clone for research at any time. With time and capability, you can also contribute code to pull request! Github is frequently used recently. I think it is essential for developers to organize this article. I hope anyone who wants to know about github can help me! This article outlines how to use github. For more information about github, see [git tutorial ]. This article is very detailed and suitable for beginners.


If gitHub is not installed on your computer, you can download and install it on gitHub for windows.

Github is an open-source code library and version control system. To implement version control, you should have basic functions such as creating a project or code library, downloading, viewing file change differences, adding files, submitting files, and merging directories. The following describes how to use it.


Ii. Usage:

(1) register a user on github.

(2) create a new code library. On the github user homepage, click "+" in the upper-right corner, and fill in some basic information:

 


After create repository: The gitDemo code library will appear on github.



Note:

Watch: Set email notification.

Star: whether to keep an eye on this project update. The literal meaning is Jixing.

Fork: Copy others' projects to your account. [Very useful. If you see a good open-source code library, fork first, clone it to the local machine, modify it, and use add, commit, and push operations, synchronize modified content to your account's code base [not the original code base ]. If you think it is necessary to merge your modifications with the original code library, you can submit a pull request and the owner of the database can choose whether to use merge. If merge is selected, the merge operation is successful. Your modifications will be updated to the original code library]


(3) The gitDemo code library has been successfully created.

First clone to local:

Clone Method 1: Run github, then clone, and follow the steps.



Clone Method 2: Run shell and use git clone command

Git clone https://github.com/androidKaKa/gitDemo

Git clone [******] supports multiple clone methods. You can try it on your own.




After the clone is successful, it will be saved to the local device:



In the gitDemo directory, only the LICENSE file is found. There is actually a hidden folder. git

The content is as follows. To avoid unnecessary harm, do not delete the files in it:



As graphic interface operations are less efficient, This article focuses on listing various operations with basic commands.

Operation 1: Cd. \ gitDemo

Note: Go to the gitDemo directory. Remember to use the Tab to automatically complete the command. To avoid unnecessary troubles, you can check whether the command is complete.

Use ls or dir to view the files in the directory: [master indicates the branch]




Operation 2: Echo "hello my github"> README. md

Note: In gitDemo, create the README. md file.



Now we need to update the README. md file to the gitDemo code base of the github account.

Operation 3:

Git status

Git diff

Note:

Git status: Check the current status. A prompt is displayed, prompting you to use the git add command to add the modified file to the commit state. The red README. md file is a modified file.

Git diff: view the differences. .



Operation 4: [Separate execution of the three commands]

Git add

Git commit-m "commit the readme file"

Git push origin master

Note:

Git add: changed the file to the commit state through add. [For details, refer to the git tutorial]

You can also use git add -- all to add all at once.

Git commit: Submit the added file

Git push: update the commit file to the code library.



Update the README. md file in the code library after successful push.





Operation 5:To better illustrate git log and version rollback. Repeat the preceding steps to add a file or folder [do not leave the folder blank] and record the two versions. The procedure is as follows:


Operation 6:Git log -- pretty = onelinegit reset -- hard HEAD ^ git reflog Description: git log: view the commit log git log: Add -- pretty = oneline summary. Git reset -- hard: Version rollback. HEAD ^ [Previous Version], HEAD ^ [Previous Version] and so on. Or use git reset -- hard commitID.


Git reset rollback version:

After the version is rolled back, you cannot view the previous commit diary information. You can view it through git reflog. Then, use commitID to jump to the desired version. For example, to modify the second version of txt:

Go back to the version in the github account: Click commit, which contains detailed records of commit,


View version: my txt file second v1
Version.txt


Operation 7:Git branch testgit checkout testecho "branch test file"> test.txt git add -- allgit commmit-m "add a file into branch test" git push origin test Description: git branch: Create a branch. Git checkout: transfers to the corresponding branch. Git push origin test updates the files in the branch.



The comparison on the Web page shows that the test.txt file is only visible in the branch before the directory is merged. Master Branch:
Test Branch:


Operation 8: git branch git megergit branch-d test
Note: git branch: View branches. The Branch has a * sign. Git meger: Merge branch. After the development is completed in the branch, it must be merged with the master branch. Before merging, jump to the branch to be merged. Merge to the master. After merging branches, commit and push updates github repository. Git branch-d: delete a branch.









Webpage display:

Delete branch: After deleting the branch, remember to commit and push it to github repository.

Github overview is complete. For more information, see references and use the Internet. The key is to apply for a github account by yourself, experience it, create a repository, Update Reference, compare the differences, fork clone add commit log diff status branch reflog reset push pull meger, and so on! Iii. References

Common git commands


Github getting started tutorial, detailed, illustrated, suitable for beginners:

Liao Xuefeng git tutorial


For details about how to edit the Markdown file **. md, refer to this article:

README. md tutorial on github


I have some shortcomings. please correct me. Thank you!


Reprinted with the source: http://blog.csdn.net/androidolblog/article/details/45823069



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.