Git tutorial under Linux system

Source: Internet
Author: User

1, first install the GIT software, installation environment is the CentOS 7.x cloud server. Use the command:

# yum install git

2. Set user name and mailbox (required):

# git config--global user.name "Your name" # git config--global user.email "[email protected]"

3, create a repository, choose a suitable place, create an empty directory:

# mkdir learngit    #在服务器中创建learngit文件夹
# CD learngit #进入learngit folder
# pwd #显示当前工作路径

Result: (with root user rights)

/root/learngit

4. Initialize this directory as a repository that git can manage, using commands:

# git init   in/root/learngit/.git/

The GIT repository has been successfully initialized and is empty, the path is/root/learngit/, and this directory is the repository that git can manage.

5. Add files to the Git repository

# vi  read.txt  #创建一个文本文件 # i  "Hello, World"    # Edit File contents
#: X #保存并退出

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

# git add read.txt

The second step git commit is to tell git with a command to submit the file to the repository:

# git commit-m "wrote a read file"

Description: The git commit command, followed by the -m  instructions for this submission, is a description of the content of the submission of the changes, which makes it easy to find the content of the version update soon.

git commit Once the command executes successfully, it will tell you that 1 files were changed and 1 lines of content were inserted (Read.txt has 1 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 tutorial under Linux system

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.