• git的一些操作命令


    一,如何修改一个commit的注释?

    root@kubuntu:/data/git/clog# git commit --amend

    说明:架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest

             对应的源码可以访问这里获取: https://github.com/liuhongdi/

     说明:作者:刘宏缔 邮箱: 371125307@qq.com

    二,Git的工作区、暂存区和版本库在什么位置

    工作区:就是你在电脑里能看到的目录。
    
    暂存区:英文叫stage, 或index。一般存放在 ".git目录下" 下的index文件(.git/index)中,所以我们把暂存区有时也叫作索引(index)。
    
    版本库:工作区有一个隐藏目录.git,这个就是Git的版本库。

    说明:index是一个二进制文件,不能直接阅读

    三,设置邮箱和用户名

    root@kubuntu:/data/git/clog# git config --global user.name "liuhongdi"
    root@kubuntu:/data/git/clog# git config --global user.email "371125307@qq.com"

    四,如何查看已配置的git项

    root@kubuntu:/data/git/clog# git config --list
    user.name=liuhongdi
    user.email=371125307@qq.com

    五,如何初始化一个本地仓库?

    在要初始化的目录下执行:git init

    root@kubuntu:/data/git/clog# git init
    已初始化空的 Git 仓库于 /data/git/clog/.git/

    说明:git仓库的目录保存在当前目录下面的.git目录下

    六,查看当前git项目的状态:

    root@kubuntu:/data/git/clog# git status
    位于分支 master
    尚无提交
    无文件要提交(创建/拷贝文件并使用 "git add" 建立跟踪)

    七,如何获取某一个分支下特定的commit,并作为一个新的commit引入到你当前分支上?

         说明:要使用 cherry-pick

    root@kubuntu:/data/git/clog# git cherry-pick 89a1b44dc8c491742382f0cb7d528a5652023ee9
    [master daa1f1f] d
     Date: Mon Feb 17 13:10:40 2020 +0800
     1 file changed, 1 insertion(+)

    八,cherry-pick时发生冲突怎么办?

         cherry-pick和merge/rebase一样,

         可能会引起冲突,

         遇到冲突时需要解决后再次提交

    root@kubuntu:/data/git/clog# git cherry-pick 6a1ea30d1f70c747d9f2bb6282b1f6b2e75ccf05
    error: 不能应用 6a1ea30... e
    提示:冲突解决完毕后,用 'git add <路径>''git rm <路径>'
    提示:对修正后的文件做标记,然后用 'git commit' 提交)
    root@kubuntu:/data/git/clog# vi a.txt
    root@kubuntu:/data/git/clog# git add -A
    root@kubuntu:/data/git/clog# git commit -m "解决冲突";

       说明:vi a.txt   是在解决冲突的示例代码

       

        

  • 相关阅读:
    大端法小端法以及判断方法
    多线程的同步互斥
    LeetCode344 字符串反转
    LeetCode977 有序数组的平方
    剑指54 二叉搜索树的第k大节点
    Linux抓包工具tcpdump使用总结,WireShark的过滤用法
    二进制部署k8s集群(8):安装容器网络插件Flannel
    python--Yaml操作
    python--读写excle执行测试用例
    python--安装、操作mysql数据库
  • 原文地址:https://www.cnblogs.com/architectforest/p/12323045.html
Copyright © 2020-2023  润新知