git的使用详解-创新互联

1.git分支操作常用命令

    查看分支:git branch

创新互联是一家专业提供北林企业网站建设,专注与成都网站设计、成都网站建设、H5建站、小程序制作等业务。10年已为北林众多企业、政府机构等服务。创新互联专业的建站公司优惠进行中。

    创建分支:git branch name

    切换分支:git checkout name

    创建+切换分支:git checkout -b name

    合并某分支到当前分支:git merge name

    删除分支:git branch -d name

    删除远程分支:git push origin :name

    撤销修改:git checkout filename

    删除文件:git rm file

   重命名文件:git mv oldname newname

    查看状态:git status

    添加记录:git add file 或 git add .

    添加描述:git commit -m "miao shu nei rong"

   修改描述:git commit --amend

    同步数据:git pull

    提交数据:git push origin name

   代码回滚:git reset --hard commit-id (--hard清除本地的所以修改,不加不会清除本地的修改)

2.git生成patch和打入patch

2.1 使用git format-patch生成所需要的patch:
    当前分支所有超前master的提交:

     git format-patch -M master

    某次提交以后的所有patch:

     git format-patch 4e16... --4e16指的是commit名

    从根到指定提交的所有patch:

     git format-patch --root 4e16

    某两次提交之间的所有patch:

     git format-patch 365a..4e16 --365a和4e16分别对应两次提交的名称

    某次提交(含)之前的几次提交:

     git format-patch –n 07fe --n指patch数,07fe对应提交的名称

    故,单次提交即为:

     git format-patch -1 07fe

git format-patch生成的补丁文件默认从1开始顺序编号,并使用对应提交信息中的第一行作为文件名。如果使用了-- numbered-files选项,则文件名只有编号,不包含提交信息;如果指定了--stdout选项,可指定输出位置,如当所有patch输出到一个 文件;可指定-o

指定patch的存放目录

2.2 patch的应用

    先检查patch文件:git apply --stat newpatch.patch
    检查能否应用成功:git apply --check newpatch.patch
    打补丁:git am --signoff < newpatch.patch

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


当前名称:git的使用详解-创新互联
当前URL:http://pwwzsj.com/article/ccgcce.html