I learn Git small notes _1

I think that first come to mind a great site to learn Git official website of Liao Xuefeng

Git is understood to have been, but not systematic, so have the following Git is the study notes

Git and SVN compare

Overall SVN is relatively easy to get started and use, Git takes a little learning costs.

  • SVN is centralized, you need to use in the case of networking, you can implement branching functionality but high cost. That is done with this intention, SVN is the sole owner of the team worthy of belief version. If you do not deal with the case of disaster recovery, but a server exploded, everything will cool the. Of course, if this situation occurred, please consider character :)

  • Git is a distributed, support offline mode, implement branching functionality and relatively inexpensive. Talking is offline, the programmer can still operate your own code, you can switch to a different branch, no big consumption.

The core concept --- Git workflow

  1. Workspace

This would not have much to say, what we really working directory.

  1. storage cache

This area holds the temporary file that we modified, of course, this is their own need to specify which files in a temporary area.

  1. Warehouse District

Warehouse District is divided into local and remote warehouse district warehouse district.

Git workflow

MarkDown how to write UML diagrams will not simply talk about the usual procedures and commands to use it.

Creating a warehouse

In fact, there are two ways to create a warehouse, a repository is created from a remote Github, Gitee other platforms, then pull down the warehouse, and the other is a local code with the git init initialization is pushed to the remote. (This method is, in fact, a little chicken aid is not recommended.)

So, create a remote repository can be created on Github, Gitee, if you want to have their own platform can take it GitLab.

Git clone cloning project

This command is to git clone remote repository code downloaded to the local, and create a remote branch name and branch of the same name and its corresponding, it is a process called cloning.

Branch exchange

Warehouse is divided into local and remote, branch naturally into the local repository.

command Explanation
git branch Check local branch
git branch -b View remote branch
local branch git checkout {name} Switching local branch
local branch git checkout -b {name}} {remote branch name Creates a local branch corresponds to the remote branch, and switch to the local branch created

During operation I prefer the following steps

Suppose now have a job, you need to switch the remote branch to do other work.

order command Explanation
1 git status View file status, you can see their own files modified, if do not want to modify the file can be undone, it can also be stored temporarily
2 git add . As the investigation did not submit the documents did not want to, you can use this command to modify the file if you only want to submit several documents can use git add {path}
3 git commit -m 'log' Add documents submitted
4 git push Push, if pushed to the other remote branches can also be specified
5 git pull In fact, this command executes two commands, pull, merge. Synchronization means that all local branches and warehouses information
6 local branch git checkout {name} Switch to the new branch work

Note that
does not necessarily have to be in the order above, for example, can create a local branch, and then pushed to the remote.

Egg parts: Part II and ready to engage in problem crlf lf under the git.

Always a tool to understand the purpose of the most important.

Guess you like

Origin www.cnblogs.com/hoyu/p/git_learn.html