Simple to use Git commands Remarks

Git is the world's most advanced distributed version control system (no one).

Many people know, Linus created the open-source Linux in 1991. Since then, the development of Linux systems, has become the largest server system software.

Although Linus created Linux, but Linux is to grow by enthusiastic volunteers around the world to participate, so many people write code for Linux around the world, and that Linux code is how to manage it?

………………………………………

Liao Xuefeng always poke the original text of the article

Linus spent two weeks own use C to write a distributed version control system, which is Git!

Create Repository

$ mkdir learngit

$ cd learngit

$ pwd

pwd command displays the current directory.

By git initcommand this directory can become a Git repository management

Initialize a Git repository, use git init command.

Add files to the Git repository, in two steps:

  • The first step in using the command git add <file>, pay attention, it can be used repeatedly to add multiple files;
  • The second step, use the command git committo complete.
  • To keep abreast of the status of the work area, use the git statuscommand.
  • If the git status tells you the file has been modified, you can view content with git diff.

Version rollback

  • HEAD points to the current version is the version, therefore, Git allows us to shuttle between the versions of the history, use the command git reset --hard commit_id.
  • Before the shuttle, with the git logcommit history can be viewed, to determine which version to fall back.
  • To return to the future, with a git reflogview command history in order to determine what you want to return to a future version.

The original text stamp Liao Xuefeng teacher article

In submitting code to the git repository when the need to always monitor the status change:

My operation is as follows:

1, git statusthe main check those files has been modified

2, git add -Ato submit a file to the local repository

3, git statuscheck submission status

4、git commit -m "说明最好见名之意"

5, git pull origin masterfirst pull other people's code

6, git push origin mastersubmit code to a remote repository

Original: Large column  simply use Git commands Remarks


Guess you like

Origin www.cnblogs.com/petewell/p/11606413.html