git general steps

Source: Internet
Author: User
Tags version control system

Creating a repository is very simple, first of all, choosing a suitable place to create an empty directory:

$ mkdir learngit$ cd learngit$ pwd/Users/michael/learngit

The second step is to git init turn this directory into a repository that git can manage by command:

$ git initInitialized empty Git repository in /Users/michael/learngit/.git/

Instantly Git has built the warehouse, and tell you is an empty warehouse (empty Git repository), careful readers can find the current directory is a directory of more than one, .git this directory is git to track the management of the repository, it's OK don't manually modify the directory inside the file , or change the mess, the Git repository to destroy.

If you don't see the .git directory, it's because the directory is hidden by default and ls -ah can be seen with commands.

(Use the Windows children's shoes to pay special attention: Do not use the TXT text tool to write code)

Add Files to Repository

Now, let's write a readme.txt file that reads:

is a version control system.Git is free software.

Be sure to put learngit it in the directory (subdirectory is also OK), because this is a git repository, put it elsewhere git can not find this file.

It takes 3 steps to put an elephant in the freezer, and it takes only two steps to put a file into a git repository.

The first step is to use the command git add to tell git to add the file to the repository:

$ git add readme.txt

Execute the above command without any display, that's right, the Unix philosophy is "No news is good news", stating add success.

In the second step, tell git with the command to git commit submit the file to the repository:

commit -m "wrote a readme file"[master (root-commit) cb926e7] wrote a readme file 1 file changed, 2 insertions(+) create mode 100644 readme.txt

A simple explanation of the git commit command, followed by the -m submission of the instructions, you can enter any content, of course, it is desirable to make sense, so that you can easily find changes in the history record.

Too much trouble not to enter the -m "xxx" line? There are ways to do this, but it's strongly not recommended, because it's important for you to read to others. I do not want to enter the description of children's shoes please google, I do not tell you this parameter.

git commitWhen the command executes successfully, it will tell you that 1 files have been changed (our newly added Readme.txt file), inserting two lines of content (Readme.txt has two lines of content).

Why does git need to add files add in commit two steps? Because commit you can submit many files at once, you can have add different files several times, such as:

$ git add file1.txt$ git add file2.txt file3.txt$ git commit -m "add 3 files."
 

 

git general steps

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.