400 028 6601

建站动态

根据您的个性需求进行定制 先人一步 抢占小程序红利时代

Git的常用操作

用户配置

1.查看用户信息

东胜网站建设公司创新互联,东胜网站设计制作,有大型网站制作公司丰富经验。已为东胜近1000家提供企业网站建设服务。企业网站搭建\外贸网站制作要多少钱,请找那个售后服务好的东胜做网站的公司定做!

全部信息:git config --global --list
用户名字:git config user.name
用户邮箱:git config user.email

2.修改用户信息

修改姓名:git config --global user.name  "名字"
修改邮箱:git config --global user.email "邮箱"

拉取代码

1.更新代码

每次写代码前,更新一下代码:git pull

2.创建分支

git checkout -b 分支名(最好与远端一致) origin/分支名

提交代码

以下操作都需要切换到提交分支

1.添加文件

(git add .) 或者是 (git add fileName)

2.提交代码

git commit -m "注释内容"

3.推送到远程分支

git push

合并代码

无冲突下

git merge branch1
git commit
git push

有冲突下

1. git merge branch1
2. 打开产生冲突的文件,根据需要将<<<<<, =====, >>>>> 符号内的代码保留,不需要的删掉后,
再把<<<<<, =====, >>>>> 符号删掉,然后继续下一步。
3. git commit
4. git push

两个分支合并冲突

1. git pull 拉取最新代码
2. git checkout -b branch1/branch2 (这里要做的是把branch1和branch2都拉到本地做合并)
3. git merge branch2 branch1 (按照上一步解决代码冲突后)
4. git commit (当前所在分支为branch1)
5. git push

代码内容出错

git fetch --all && git reset --hard origin/develop && git pull
舍弃当前修改,强制拉新代码覆盖掉

网站题目:Git的常用操作
文章路径:http://mbwzsj.com/article/dschihe.html

其他资讯

让你的专属顾问为你服务