欢迎登陆真网站,您的到来是我们的荣幸。 登陆 注册 忘记密码? ☆设为首页 △加入收藏
欢迎加入真幸福QQ群
电脑知识: 基础知识 网络技术 操作系统 办公软件 电脑维修 电脑安全 windows7 windows8 windows10 服务器教程 平板电脑 视频播放教程 网络应用 互联网 工具软件 浏览器教程 QQ技巧 输入法教程 影视制作 YY教程 wps教程 word教程 Excel教程 PowerPoint
云南西双版纳特产小花糯玉米真空包装


linux中利用Shell脚本自动提交网站404死链到搜索引擎
解决windows server 2008图片文件无法显示缩略图问题
如何打造最安全的服务器虚拟化环境
WEB专用服务器的安全设置的实战技巧
网管经验谈 服务器常见软件故障解析
对于服务器而言什么最重要
iptables防火墙只允许指定ip连接指定端口、访问指定网站
谷歌android m什么时候发布
SLICY MAC下的切图神器!
音乐云盒怎么把普通音响变成无线Hi-Fi音响?
git命令添加 修改 删除 冲突解决办法
【 来源:网络 】【 点击:1 】 【 发布时间:2017_03_03 08:59:59 】

   如果对git命令行不熟悉的话,用git图形界面工具,就比较合适了。建议使用tortoisegit这样的工具,命令行从学习到灵活掌握的时间成本比较高的。

  1,添加

  # git clone git@192.168.10.202:develop/test.git

  # cd test

  # touch test.txt //测试文件

  # git add test.txt //git添加文件

  # git commit -m 'test' //添加到本地版本库

  # git push //push到远程

  如果push报错,Perhaps you should specify a branch such as 'master'

  解决办法:

  # git push origin master //只要这样操作一次,以后就可以用git push

  添加文件和添加目录,操作是一样的。

  2,修改文件

  方法一

  # echo "11111111111" > test.txt

  # git add test.txt && git commit -m 'test2'

  # git push

  方法二

  # echo "abc" > test.txt

  # git commit -am "test3" //所有修改都会提交

  # git push

  如果有多个文件,只想提交其中的一个或者多个,怎么办呢

  # git commit -a //该命令出现以下内容

  # Please enter the commit message for your changes. Lines starting

  # with '#' will be ignored, and an emptyempty message aborts the commit.

  # On branch master

  # Changes to be committed:

  # (use "git reset HEAD ..." to unstage)

  #

  # modified: ab

  # modified: test.txt //如果只想提交test.txt,只要把该行前的#去掉,保存退出就行了

  # git push //退出后,在执行push

  3,删除

  # git rm ab //如果删除目录的话,加上-r

  # git commit -am "del"

  # git push

  4,解决冲突

  # git push //push不上去

  Address 192.168.10.202 maps to unassigned.psychz.net, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!

  To git@192.168.10.202:develop/test.git

  ! [rejected] master -> master (non-fast-forward)

  error: failed to push some refs to '192.168.10.202:develop/test.git'

  To prevent you from losing history, non-fast-forward updates were rejected

  Merge the remote changes before pushing again. See the 'Note about

  fast-forwards' section of 'git push --help' for details.

  # git pull //更新代码,提示冲突

  Address 192.168.10.202 maps to unassigned.psychz.net, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!

  remote: Counting objects: 5, done.

  remote: Compressing objects: 100% (2/2), done.

  remote: Total 3 (delta 0), reused 0 (delta 0)

  Unpacking objects: 100% (3/3), done.

  From 192.168.10.202:develop/test

  367dad3..5e5640b master -> origin/master

  Auto-merging test.txt

  CONFLICT (content): Merge conflict in test.txt

  Automatic merge failed; fix conflicts and then commit the result.

  # vim test.txt //修改冲突文件,并保存

  # git commit -am "remove conflict" //重新提交到本地版本库

  # git push //同步到远程

本网站由川南居提供技术支持,fkzxf版权所有 浙ICP备12031891号
淳安分站 淳安分站