Git's Build repository

Source: Internet
Author: User
Tags commit version control system

git, in fact, I began to contact early, and began to understand some knowledge, and then developed with the development of tools to the remote push code, but found that they do not know much about git, they do not work hard, a day of conscience found, feel sorry friends to provide information and help, so they spent a few days, The git command, from the repository to the remote push, manages the code, revokes it, modifies it, deletes it, and understands that the understanding is certainly deeper than before, with this record deepening the impression.

The premise of the operation is that Git is already installed on your computer.

The first step: Find a suitable place to create an empty directory

$ mkdir learngit
$ cd learngit
$ pwd
/g/gitexample/learngit

The PWD command is used to display the current directory. This warehouse is located in/g/gitexample/learngit

Step Two: Use the git init command to turn this directory into a repository that git can manage:

$ git init
Initialized empty git repository in g:/gitexample/learngit/.git/

Instantly git builds an empty repository, and a. git file is available in the current directory, which is used by git to manage the tracking repository, instead of manually changing the Git repository.
If you don't see the. git directory, it's because the directory is hidden and can be seen with the Ls-ah command.

Step Three: We create a Readme.txt file in this warehouse

$ touch Readme.txt
//Add content
$ echo "Git is a version control system" >> readme.txt
//View file contents
$ cat Readm E.txt
//Find out what
Git is a version control system

Fourth Step: Add Readme.txt to the warehouse

$ git add readme.txt
$ git commit-m "wrote a Readme file"

Git commit command,-M followed by the submission of the instructions, you can enter any content, of course, it is useful to make sense, so that you can easily find changes in the history record.

You can add different files multiple times, commit can commit many files at once.

Fifth Step: View the Commit log

$ git log
commit 928f4b4230cf9440d61e5d7ef2dc70a8c5b10eb6
author:xxxxx<xxxx@qq.com>
Date:   Tue Jul 18:01:35 +0800

    wrote a reademe file

Sixth step: view Operation History

$ git reflog
928f4b4 head@{0}: Commit (initial): wrote a reademe file

To create a repository, it's basically here.

More knowledge, can Liao Xuefeng Master's official website, thank you ~ ~

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.