git管理命令

# 克隆代码到本地 > git clone https://github.com/yangjianbo/test_project

#查看代码更新
> git status

#
把所要条件的代码提交给git去管理
>git add test.py

#
提交代码,本地提交版本提交
> git commit -m "提交代码" (提交代码,本地提交)
#提交到远程仓库

> git push origin master (提交到远程仓库)

#分支管理项目
#查看当前分支
> git branch -l 

#创建分支
> git branch xxx 

#切换分支
> git checkout xxx

#合并分支(合并分支,把dev分支的合并到master分支)
> git merge dev

代码冲突解决:
如果A开发改动了test.py代码,B开发也改动了test.py这个文件的代码
就会导致文件冲突
> git pull (拉取代码的时候有冲突)
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/yjbtest/test_dev
d206c2d..eb13c49 master -> origin/master
error: Your local changes to the following files would be overwritten by merge:
test.py
Please commit your changes or stash them before you merge.
Aborting
首先提交有冲突的文件
> git add test.py
> git commit -m "A开发的修改"
然后解决冲突
> vim test.py (解决有冲突的文件)
> git add test.py (提交到git)
> git commit -m "A和B商量后的共同修改" (本地提交)
> git push origin master (提交到远程仓库)



猜你喜欢

转载自www.cnblogs.com/QAyangjianbo/p/11824540.html