• Git操作手册记录


    Git使用指南

    查看tag所在分支

    git branch --contains tags/<tag>

    0.删除远程tag

    git tag -d tag_name
    git push origin :refs/tags/tag_name

    删除远程分支
    第一种方案:
    1.先删本地分支
    git branch -d localbranch_name
    2.删远程分支
    git push origin :branch_name

    第二种方案:
    git push origin --delete branchname  (直接删远程分支)


       重命名本地分支

      git branch -m old_branch_name new_branch_name      

    1.查看历史tag
    git log --pretty=oneline --abbrev-commit //查看历史tag

    git tag //查看历史tag

    git show <tagname> //查看指定tag指的commit内容

    git tags --push //推送本地tag

    git fetch origin tag <tagname> //获取远程tag

    2.暂存
    git stash //暂存本地修改

    git stash list //查看当前储藏
    stash@{0}: WIP on master: 049d078 added the index file

    git stash apply stash@{2} //应用指定的储藏

    git stash pop //应用暂存内容

    git stash apply //应用暂存内容 不删除stash

    1.场景1:应用储藏后修改文件后想撤销储藏
    git stash show -p stash@{0} | git apply -R
    2.场景2:储藏之后修改文件,想应用储藏,可能会有冲突,应用储藏时把储藏应用在新建分支上
    git stash branch testchanges

    3.分支
    git reset --hard HEAD^ //回退版本,HEAD指向的版本就是当前版本,因此,Git允许我们在版本的历史之间穿梭,使用命令git reset --hard commit_id。

    穿梭前,用git log可以查看提交历史,以便确定要回退到哪个版本。

    要重返未来,用git reflog查看命令历史,以便确定要回到未来的哪个版本。

    git checkout -b dev_zhengwang orgin/dev_zhengwang //新建本地分支跟踪远程分支

    git branch -u origin/dev_zhengwang //切换跟踪远程的分支

    git fetch origin //将本地origin/dev_zhengwang远程跟踪分支和远程分支同步

    git branch -vv //查看本地分支和远程跟踪分支指向的commit的区别

    git push origin dev//推送本地dev分支到远程

    git branch -m <oldname> <newname> //分支重命名

    git branch -m <newname> //当前分支重命名

    git checkout branch-name //切换分支

    git commit -m 'comment info' //提交信息

    git checkout -b 'branch-name' //切换到新分支

    git push --set-upstream origin DEV_20171012_apollo
    //重命名远程分支
    $ git branch new-branch-name origin/old-branch-name
    $ git push origin --set-upstream new-branch-name
    $ git push origin :old-branch-name //删除远程old-branch-name分支
    4.回退

    git log //查看历史commit

    git reset --hard commitid

    git reflog //查看未来commit

    git reset HEAD file //把暂存区的修改回退到工作区

    git checkout -- file.txt //把文件从工作区回退到工作区之前干净状态

    场景:

    在DEV分支提交某个commit,理应在DEV_2018****开发分支提交的

    1.  可以将DEV分支合并到DEV_2018****开发分支

    2.  然后将DEV分支 git reset --hard commitid 回滚到历史版本

    3.  然后强制推送远程分支  

    git push origin HEAD --force

    5.git忽略文件权限的变化
    git config core.filemode false

    6.每过一个发版日都需要合并一次master分支

    7.reg tag打在dev分支上,在reg

    场景:

    出现如下问题:

    1. fatal: 'origin' does not appear to be a git repository fatal: Could not read from remote repository.

    2. Git push: “fatal 'origin' does not appear to be a git repository - fatal Could not read from remote repository.”

    1. git remote -v //查看当前远程分支

    2.如果没有任何信息 执行 

    git remote add origin git@git.***corp.com:ext-ds/***.git

    3.执行如下

    git push origin master
    git branch --set-upstream-to=origin/master master
    git pull
    欢迎关注Java流水账公众号
  • 相关阅读:
    windows服务器性能监控工具、方法及关键指标
    js加密的密文让PHP解密(AES算法)
    在CentOS上搭建PHP服务器环境
    开发php的扩展模块(centos环境下)
    年终培训关于磁盘冗余阵列、热备、群集、负载均衡、云计算、F5、Nginx等的概念和基本原理
    5分钟开发一个简单的基于HTML5的移动应用
    【JAVA WEB教程】jsp环境搭建+部署网站(eclipse+tomcat)【详细+图文】
    linux图形化客户端
    【JAVA WEB教程】jsp环境搭建(eclipse)【详细+图文】
    如何预估服务器带宽需求【转】
  • 原文地址:https://www.cnblogs.com/guofu-angela/p/9212269.html
Copyright © 2020-2023  润新知