Concise git tutorial (single-user version) and git tutorial

Source: Internet
Author: User

Concise git tutorial (single-user version) and git tutorial

Recently, I started to write a relatively large project, so I need to use git. I have been using SVN built with Kingsoft kubernetes and turtles. Recently I want to try git.

1. Install

Ubuntu:

1 sudo apt-get install git

In earlier versions of Ubuntu:

1 sudo apt-get install git-core

For other versions of Linux, You need to download the source code from the official website for installation.

1 ./config2 make3 sudo make install
2. Create a version Library
Mkdir sexybearcd sexybearpwd (pwdCommand to display the current directory) git init (git initCommand to change this directory to a Git-managed repository)

Now go to the sexybear folder and. git directory. This indicates that the repository has been created. If yes, it will not fail. It may be that the directory is hidden and you can use ls-ah to view it.

A repository that can be managed by git is created, and the next step is how to add files.

First, create a new file in the sexybeardirectory, such as readme.txt.

Then, execute the following command to tell git that you have added a file.

1 git add readme.txt2 git commit -m "wrote a readme file"
3. Version Control

1. view the git status and specific changes

1 git status2 git diff readme.txt 

The second directive shows the specific changes to the readme.txt file.

2. Version rollback

1 git log2 git log -- pretty = oneline3 git reset -- hard HEAD ^ (back to the previous version) 4 git reset -- hard 3628164 (back to the specified version number, the version number can be obtained in log)

3. Cancel Modification

Git checkout -- readme.txt (readme.txtAll file modifications in the workspace are revoked)

4. delete an object

Git rm readme.txt (delete the files that have been submitted to the repository)

Now these commands are enough for single-person work. I don't need them for team work yet, so they won't be involved and will be improved in the future.

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.