Git-series git command learning

Source: Internet
Author: User
Tags commit git clone git commands

Git that took so long, didn't come and summed up the next common git commands, today is free to briefly summarize the common GIT commands in the project, as well as some basic concepts.

I think there are 10 things that are important, because after all, I'm not a Git version control expert, I feel that understanding these in the daily development can be:

(1) Create a new repository git init

(2) Checkout repository git clone/path/respository (checked out from the local repository)

git clone username@host:/path/respository (remote server repository)

(3) Understand the good workflow:

In fact, it is mainly three trees, one is the work area, one is a buffer zone, and the other is head, it points to the results after the last commit

(4) Add and submit git add <filename> git commit-m "comment content"

(5) Push to change GIT push Origin master the master here can be changed to any branch you want to push.

If you are not cloning an existing repository and want to connect your warehouse to a remote server, then we can first:

Git remote add origin<server> so you can push your changes to the added service

(6) Branch: In fact, the main function of the branch is to separate the characteristics of each other. When we create a warehouse, we create a master branch by default, and we can do it on other branches

To be developed and then merged into one branch after completion.

First we can create a branch feature git checkout-b feature

And then we'll cut back to the main branch git checkout Master

Then remove the new branch from Git branch-d feature

(7) Updating and merging

Update the repository to the latest version of Git pull

Merge other branches into your own branch git merge <branch>

But in this process, sometimes inevitably encounter some conflict, that is, branching and branching, so this time we have to do is to resolve the conflict, we can use

Compare ..., specifically forget, to carry out file differences, find out exactly where the branch problem, resolved after the commit git add <filename>, of course we can also through the Git diff <source_branc H> <target_branch> See where the changes are.

(8) Create a tag, or create a signature, the command is also very simple, when we complete the software changes, git tag 1.0.0 +id This ID we can get: git log;

(9) A more commonly used fix, or a version fallback tool, we can use git checkout--<filename> to roll back the version to the head to the work area to leave.

(10) The last one is that we define the GIT output style, but I do not use much, the need for friends can go to understand.

Well, today I'll talk about it, and then we'll continue to talk about some of the features of Git versioning, as well as some issues to keep in mind.


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.