Create repository and local warehouse related operations

Source: Internet
Author: User

  To create an empty directory :

$ mkdir learngit$ cd learngit$ pwd/users/gaoswaotu/learngit

PWD: Displays the current directory.

  

  Initialize the warehouse:

through git init command to turn this directory into Repositories that git can manage:

 in/gaoswaotu/learning/.git/

Warehouse is built, and is an empty warehouse (empty Git repository), the current directory is more than one . Git directory , this directory is git to track the management repository, the directory is hidden by default, with Ls-ah command can be seen.

  

Put a file in   The git repository takes only two steps .

The first step is to use the command git add tells git to add files to the repository:

$ git Add text.txt

Step two, use the command. git commit tells git to commit the file to the repository:

" wrote a textfile " [Master (Root-12 insertions (+100644 text.txt

  Git commit-m "wrote a Readme file"

  - M The following input is the description of this submission, you can enter any content, of course, it is best to make sense, so that you can easily find changes in the history record.

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

Note: The command git add <file> can be tried over and over again, then git commit one commit at a time.

  Other Related commands:

  Touch test.txt : Create a text.txt file;

  vim test.txt : Edit the text.txt file by pressing "ESC", then the keyboard beats ": Wq" (: Wq Save and exit Vim Editor; : w save content without exiting Vim Editor );

g   It status : keep track of the status of your workspace, if git status tells you that files have been modified, use git diff View the modified content;

  git log : shows the commit log from the most recent to the farthest, output too much information, git log--oneline available

  git reset--hard head^ : git reset fallback command head^ represents previous version,head^^ represents previous version, /c8>head~100 on a version

  git reset--hard 123456 : Fallback to the specified version 123456 the commit ID through git log< the/c6> command can query the commit ID of each version

To revert to a version, use the git log You can view the commit history to determine which version to fallback to.

to return to the future, use git reflog View the command history in order to determine the return which version of the future

Ha!!! There is also a diagram of common commands:

From: Http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/ 0013743256916071d599b3aed534aaab22a0db6c4e07fd0000 and http://www.liaoxuefeng.com/wiki/ 0013739516305929606dd18361248578c67b8067c8c017b000/0013743858312764dca7ad6d0754f76aa562e3789478044000

Create repository and local warehouse related operations

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.