首页 > 其他 > 详细

Git得操作方式

时间:2021-06-03 14:14:11      阅读:6      评论:0      收藏:0      [点我收藏+]

Git

git: 代码分布式版本控制系统

初始化仓库

在目录project对应的终端上

git init  # 初始化仓库

初始化项目

 django-admin startproject admin_django  # 创建django项目
vue init webpack admin_vue  # 创建Vue项目
# 添加.gitignore文件

添加、提交

git add .  # 添加代码到缓存区
?
git commit -m ‘项目初始化‘  # 提交改变的代码

 

查看所有分支

git branch  # 当前所在的分支名前,会有一个 *
?
* master

创建新分支

git branch test  # 创建新分支

切换分支,

git checkout test  # 注意:分支test需要先创建,才能切换
?
?
git checkout -b test2  # 创建并切换到新分支test2

合并分支

git checkout master # 切换到分支master
?
git merge test  # 合并test分支到主分支

删除分支

git branch -d test

代码冲突

  • master 分支

  • test分支 在没有同步 master的时候,也修改 1.txt 文件,添加、提交

  • 最后,在master分支, 合并test分支时,会出现 代码冲突

$ git merge test
Auto-merging 1000.html
CONFLICT (content): Merge conflict in 1000.html
Automatic merge failed; fix conflicts and then commit the result.
?
$ git add .
$ git commit -m ‘代码冲 突‘
[master 95741e6] 代码冲突
?
$ vi 1000.html  # 修改1.txt,解决冲突
$ git add .
$ git commit -m ‘解决代码冲 突‘
[master 84e6f78] 解决代码冲突
1 file changed, 4 deletions(-)

 

Git得操作方式

原文:https://www.cnblogs.com/lry250/p/14844519.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!