Toc
  1. 管理员视角
    1. 场景一
    2. 场景二
  • 用户视角
    1. git快速上手
    2. git目录下的一些配置解读
  • Toc
    0 results found
    Salieri
    git备忘录
    2020/07/28 Notes git linux

    管理员视角

    场景一

    忍受不了github的网速/不放心代码托管平台的数据安全/无所谓图形化界面。

    创建本地git远程仓库充当git服务器

    sudo git init --bare repo.git

    考虑到可能会多人使用(实验室、小公司),把仓库所有者设置为多人用户组

    chown -R git:groupname repo.git

    变更读写权限

    chomod -R 775 repo.git

    变更目录属性,让此目录下创建的文件继承该目录属性。参考setuid 没有这一步其他用户无法对仓库操作

    cd repo.git
    chmod g+rws objects/
    chmod g+rws refs/

    修改git仓库配置文件vim repo.git/config。在最后一行添加sharedRepository = 1。切换至其他用户测试git仓库。

    此方式创建的git仓库,可以局域网共享。使用方式为

    git clone ipaddress:/repo.git
    cd repo.git
    git remote remove origin
    git remote add origin username@ipaddress:/repo.git

    场景二

    场景一的基础上条件上,希望能使用图形界面。

    配置gitlab-ce。参考Docker+gitlab搭建自己的代码仓库

    用户视角

    git快速上手

    • 创建git仓库

      mkdir testrepo
      cd testrepo
      git init
      git config user.name "name"
      git config user.email "name@domain.com"

      配置user.names/email时可选--global参数,全局配置。

    • 常用命令

    命令 功能描述
    git add 添加到暂存区
    git status 查看当前暂存区状态
    git commit 添加commit
    git log 查看历史commit
    git remote 配置远程仓库
    git push 推送
    git pull 拉取
    git checkout 操作分支

    参看各类教程,掌握以上几个命令,即可完成git常用操作。

    遇事不决git cmd --help

    git目录下的一些配置解读

    文件名 功能
    .gitignore 忽视指定文件/目录
    .gitmodule 在git仓库中添加其他仓库作为子模块
    打赏
    支付宝
    微信
    作者:Salieri
    本文基于CC BY-NC-SA 4.0许可协议发布,欢迎转载,演绎,但是必须保留本文署名,且不得用于商业目的。如您有任何疑问或者授权方面的协商,请与我联系