Git learning and stepped pit

  In the current project work, a person to complete a major project in general are very difficult, so many people work together to complete the project will need to use Git code management tool. I recommend learning Git can look Liao Xuefeng teacher Git tutorial: https://www.liaoxuefeng.com/wiki/896043488029600 . The following is a step on pit situation and experiences of my learning process.

   A, Git Introduction

  Git is an open source distributed version control software for efficient, high-speed processing from very small to very large project version management. Git was originally developed by Linus Torvalds designed and developed to manage Linux kernel development. Git is based on free / free software GNU General Public License version 2 of the terms of distribution, installation, see: http: //git-scm.com/.

  When using Git as a code management tool, you need to create your own remote repository GitHub code or cloud, use GitHub, domestic users often encounter the problem of access is too slow and, sometimes, the situation can not be connected. So choose to use the code cloud is the most important: Chinese! ! !

   Two, Git in the project based on the use

Create a new warehouse

Create a new folder, open it, then 
git init
to create a new git repository.

The detection Warehouse

Execute the following command to create a local repository of clones:
git clone /path/to/repository 
If the warehouse on a remote server, your command will look something like this:
git clone username@host:/path/to/repository

Workflow

Your local git repository maintained by the three "tree" component. The first one is yours  工作目录, which holds the actual file; the second is  缓存区(Index)that like a cache area, temporarily save your changes; and finally  HEAD, pointing to the results of the most recent time you submit.

Adding to submit

You can schedule change (add them to the buffer zone), use the following command:
git add <filename>
git add *
This is the first step in the basic git workflow; use the following command to actually commit changes:
git commit -m "代码提交信息"
Now, your changes have been submitted to  the HEAD , but not to your distal warehouse.

Push changes

Your changes are now in a local warehouse  HEAD  in the. Run the following command to commit these changes to the remote repository:
git push origin master
can  master  into any branch you want to push. 

If you have not cloned an existing warehouse, warehouse and wishing you connect to a remote server, you can use the following command to add:
git remote add origin <server>
so you'll be able to push your changes to the server added go up.

Branch

Is used to branch off the insulating properties develop. When you create a warehouse, Master  is "default." Development on the other branches, and then complete the merge them into the main branch.

Create a branch "feature_x" called, and switch over:
git checkout -b feature_x
switching back to the main branch:
git checkout master
and then delete the new branch:
git branch -d feature_x
Unless you will be pushed to the distal branch warehouse, otherwise the branch is  not seen as others :
git push origin <branch>

Update and merge

To update your local repository to the latest changes, execute:
git pull
to your working directory  to obtain (fetch)  and  merge (merge)  changes in the distal end.
Other branches to be merged into your current branch (eg master), execute:
git merge <branch>
in both cases, git will attempt to merge the changes automatically. Unfortunately, not bottom in automatically merged successfully, and could lead to  conflict (a Conflicts) . This time you will need to modify these files come meat merge these  conflicts (conflicts)  a. When you're done, you need to execute the following command to mark them as successful merger:
git add <filename>
before merging changes, you can use the following command to view:
git diff <source_branch> <target_branch>

 Three, Git learning experience

  Keys remote cloud configuration code repository: https://www.liaoxuefeng.com/wiki/896043488029600/1163625339727712

  Use VS code integration git operations: https://blog.csdn.net/zuofanxiu/article/details/80962134

 

 

Guess you like

Origin blog.csdn.net/qq_40128701/article/details/90665052