Git is designed for many guy’s corporation concurrently.
1.1 Concept
CVCS:中央分布式控制系统,typical:SVN
DVCS:Git;
Git accounts up 74%,and svn accounts up 22%;
Difference:CVCS means 中央版本控制系统必须同时存在服务端和客户端,在业务流程过程中,服务端必须存在,所有请求必须经过服务端的处理。
DVCS:主要是将备份的代码以及记录完全独立在本地存储。本地版本控制器不需要依赖网络便可以完成此操作.
How to install Git under windows/linux/mac;
1.Windows: Download git-for-windows;
2.Linux: apt-get install / yum install …
3.Mac: brew install git;assumption that you have installed Homebrew.
1.2 Basic operaion
1 Repo
It means that It includes all file,directory.
- Create Repo
mkdir oop_git
cd oop_git
git init
- Add for add files and change files.
touch test.py
git add test.py; git add .(means add all files)
- Commit Repo when add or modify files
git commit -m "add test.py"
- View history
git log
- Revert Reversion
git reset --hard <Version> //Version Description:1.head,head^; 2. ID
2.Working Direc,Stage,Repository
Working Direc means current files in local computer.
Stage:Storage all changes tempally;
Repository: Storage for git commit ;
1.3 Branching
Create a Branch only for Personal develop.Others cant see it.
At the beginning,head -> master;
git checkout -b dev "means create a new branch called dev;
git branch "For View all branches.
After that,all changes and commits works dev-branch.
git checkout master "Switch to master
git merge dev "For merge dev
git branch -d dev "For del dev-branch
1.4 Solve Conflicts when git merge…
Especially: git-log-graph for View branch graphic.
git add & git commit is neccessery.
Reference: https://www.liaoxuefeng.com/wiki/896043488029600/1216289527823648
1.5 Remote Repo for use
- github:for code storage freely;
- clone remote repo to local directly
git clone git@github.com:xxx "Means take remote repo into local computer and create working Direc;
- git init Started
git remote add origin <Repo HTTP/SSH> "origin is alias of RepoName;
1.6 git push origin master
When finished all Add and Commit,You can use git push origin master for sync branch record.文章来源:https://www.toymoban.com/news/detail-580523.html
1.7 git push origin master
For update latest code(Maybe added by others);
正常的推送更改流程为:先更新本地最新代码,再先 Add 和 Commit 本地修改,然后拉取远端更改,如果此时出现了合并冲突(英文:Merge Conflict),解决合并冲突。然后,在合并冲突解决后推送更改。文章来源地址https://www.toymoban.com/news/detail-580523.html
到了这里,关于【Git Concept】的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!