git--Easy Guide

Source: Internet
Author: User
Tags git workflow git cheat sheet

For me, git just knows it's a version controller, similar to the turtle's SVN. There are only a few common commands, such as "Update Git Pull", "commit git push" and so on, because remember the original use, Master told me, for you do not understand this does not matter, remember a few common commands are enough to use.

The teacher's words are not wrong, there are these commands are enough to use, but sometimes it is difficult to complete the requirements of our work, such as how to install, how to create a library, and so on, which are not possible to achieve a few commands. Only pity oneself too lazy, so every time when use need to find relevant information, really face the Jiangdong elders ah.

Today's email received a resource about the Git guide, it is really fresh and beautiful, a few words to Git said clearly, it is supposed to talk about, and is simple and clear. And found that it has a Chinese version, specifically the Chinese version of the move to a small station, to share with you.

git Easy Guide Chinese

A handy guide to getting Started with git, with advanced content,;).

Address: http://rogerdudler.github.io/git-guide/index.zh.html

Roger Doudler

Special thanks: @tfnico, @fhd and Namics

English version, and other language versions, please refer to: git-the Simple guide

Next go to the topic, I will directly move the Chinese version of the content here:

Installation

Download the required files before installing:

Download git OSX download git Windows version download git Linux version

Create a new warehouse

Create a new folder, open it, and then execute:

Git init

To create a new git repository.

Check out the Warehouse

Execute the following command to create a cloned version of the local repository:

Clone/path/to/repository

If this is the repository on the remote server, your command will look like this:

git clone username@host:/path/to/repository 
Work flow

Your local repository consists of three "trees" maintained by git. The first one is your working directory , it holds the actual file, the second is the buffer (Index), it's like a cache area, temporarily saves your changes, and finally the HEAD, which points to the result of your last commit.

Add and submit

You can schedule changes (add them to the cache) and use the following command:

<

This is the first step in the Git basic workflow, using the following command to actually commit the changes:

Now, your changes have been submitted to HEAD, but not to your remote repository.

Push changes

Your changes are now in the HEAD of the local repository. Execute the following command to commit the changes to the remote repository:

You can replace master with any branch you want to push.

If you have not cloned an existing repository and want to connect your warehouse to a remote server, you can add it using the following command:

<

So you can push your changes to the server you added.

Branch

Branches are used to insulate the development of features. When you create a warehouse, Master is "default." Develop on other branches, and then merge them onto the main branch when you are finished.

Create a branch called "feature_x" and Switch to the past:

Switch back to the main branch:

Then delete the new branch:

Unless you push the branch to the remote repository, the branch is not visible to others:

<
Update and merge

To update your local repository to the latest changes, do the following:

To get (fetch) in your working directory and merge (merge) remote changes. To merge other branches into your current branch (for example, Master), execute:

<branch>

In both cases, Git will try to automatically merge the changes. Unfortunately, automatic merging is not always successful, and can lead to conflicts (conflicts). This time you need to modify these files to human flesh merge these conflicts (conflicts). After you've changed, you'll need to execute the following commands to mark them as merged successfully:

<filename>

Before merging the changes, you can also use the following commands to view:

<<target_branch> 
Label

It is recommended to create a label when the software is published. This is an old concept, also in SVN. You can execute the following command to create a label called 1.0.0:

git tag 1.0.0 1b2e1d63ff

1B2E1D63FF is the first 10 characters of the commit ID you want to tag. Use the following command to get the commit ID:

Log

You can also use the submission ID for fewer of the first few, as long as it is unique.

Replace local changes

If you do something wrong (naturally, this is not possible), you can replace the local change with the following command:

<filename>

This command replaces the files in your working directory with the latest content in the HEAD. Changes that have been added to the cache, as well as new files, are unaffected.

If you want to discard all of your local changes and commits, you can get the latest version on the server and point your landlord branch to it:

git fetch origingit reset--hard origin/master
Useful tips

Built-in graphical git:

Gitk

Color git output:

True

When the history is displayed, only one line of comment information is displayed:

Format.pretty Oneline

To add files interactively to the buffer:

Git add-i
Graphical interface of links and resources:
    • GITX (L) (OSX, open source)
    • Tower (OSX)
    • Source Tree (OSX, free)
    • GitHub for Mac (OS X, free)
    • Gitbox (OSX)
Guides and Manuals
    • Git Community Reference Book
    • Professional Git
    • Like git thinking
    • GitHub Help
    • A graphical Git guide
Extended Reading
  1. GitHub Usage Tutorials
  2. Git on Windows for Newbs
  3. Git User Guide
  4. Top Ten Git Tutorials for beginners
  5. Git verything is local
  6. Git fast version control
  7. Graphical installation of Git under the WinXP system
February 12, 2014 update:

The following information comes from Kevin Liew's "Understanding Git" article, which organizes a series of tutorials about git operations, free books, command queries, videos, and clients under different operating systems, and so on, which interested students can look at.

Articles
    • Easy version Control with Git
    • Git-the Simple Guide
    • Free web-based GitHub and Git training from GITHUB training
    • Git immersion-git Guided Tour
    • Git for designers
    • A List apart-get Started with Git
    • GIT-SVN Crash Course
Free E-books
    • Git Command Line Cheat sheet
    • git Cheat sheet from git Tower
    • Visual Git Guide
    • Git Cheat Sheet
    • Understanding the GitHub Workflow
Video
    • Intro to Git Workflow
    • O ' Reilly webcast:git in one hour
Git clients for Mac, Windows & Linux
    • Git Tower-mac
    • Git Box-mac
    • Gitx-mac
    • Github for Mac-mac
    • Tortoisegit-win
    • Github for Windows-win
    • Git Extensions-win
    • Sourcetree-mac, Win
    • Ungit-mac, Win, Linux
    • Ftploy-mac, Win, Linux
    • Git Cola-mac, Win, Linux
    • Giteye-mac, Win, Linux
    • Smartgit-mac, Win, Linux

If you want to reprint, please specify the source:

English version Source: http://rogerdudler.github.io/git-guide/

Source of Chinese version:

Http://rogerdudler.github.io/git-guide/index.zh.html

Http://www.w3cplus.com/tool/git-guide.html

git--Easy Guide

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.