Use Git to manage local projects

Source: Internet
Author: User

1. Background

Recently, I plan to use git to manage local projects. There is a lot of information on the Internet, but this is complicated.

2. Use git

(1) initialization

Create a git folder, cd in, and create a code repository

Git init

Go to the folder and hide the file. The. git file is generated, as shown in figure

Put the project to be managed in this git folder, or clone the required project from the server. I put testDraft in.

Enter the following command to view the status.

Git status

It will prompt you for git add or git commit this operation. Because we added a project to the code library and didn't add it to the git sequence, because git is distributed and managed, we need to add each file to the head directory, the commit description is required for each modification. The following describes the project.

Git add testDraft

Git commit-m "init the project"

Then git will list all the modifications made this time.

(2) modify and restore a file

First, we can modify a file, resource. properties. As shown in figure

Add a paragraph in it, "this is a test"

Then, add and commit the file and submit the file.

28852262 @ cnbjlx20155 :~ /Git $ git add testDraft/resource. properties
28852262 @ cnbjlx20155 :~ /Git $ git commit-m "test1"

We can view this modification.

Git log

We can see that the hash code of each commit

Copy any hash code and enter the following code to view the changes.

Git show dcf7c11e403f7e4ff129aab01e6b6962e1120a77

Next we will use the restoration function to return to before adding this is a test statement.

First, copy the modified commit code, that is, the yellow code in

Enter git revert + yellow code in shell

Git revert dcf7c11 .......

The following content is displayed:

Press ctrl + x to exit and find that "this is test" has been deleted.

Git details: click here
Git: click here

Recommended reading:

Fedora downloads Git through Http Proxy

Install Git on Ubuntu Server

Create a Git repository on the server (Ubuntu)

Git simple tutorial in Linux (taking Android as an example)

Git authoritative guide PDF

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.