• git 上传文件到gitlab


    1.登录

    首先进入需要上传的文件夹,鼠标右键点击Git Bash Here

    #输入用户名、邮箱
    git config --global user.name "Your Name"
    git config --global user.email "xxx@qq.com"
    //查看设置
    git config --list
    

    2.生成公共密钥

    ssh-keygen -t rsa -C "xxx@qq.com"
    

    生成密钥的位置在:

    C:\Users\Administrator\.ssh
    

    在这里插入图片描述

    打开 id_rsa.pub,复制密钥,粘贴到下图中,点击增加密钥。

    在这里插入图片描述

    3.配置路由到hosts文件

    当你出现报错:

    ssh: Could not resolve hostname xxx.com: Name or service not known
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    

    在这里插入图片描述

    解决:
    在C:\Windows\System32\drivers\etc中,配置hosts文件
    右击hosts文件,并以记事本格式打开。然后在文件最后一行添加如下内容:
    xxx.xxx.xxx github.com

    4.初始化

    输入git init,初始化git相关配置文件

    git init

    5、设置本地与远程仓库的链接

    输入git remote add origin *你的远程仓库地址*,设置本地与远程仓库的链接

    git remote add origin http://gitlabxxxxx.git

    如果不设置会出现:

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

    6、拉取远程仓库

    输入git pull origin master,将远程仓库进行下拉,获取同步

    git pull origin master

    7、添加上传文件

    输入git add . ,将所有文件添加

    git add .

    8、暂存文件

    输入git commit -m “add new file”,提交代码

    git commit -m “add new file”

    9、提交暂存文件到指定分支

    输入git push origin master,将代码上传至远程仓库的master节点

    git push origin master

    9.指定和修改author信息

    基本语法是:
    git commit --author=“Author Name email@address.com
    这会将该commit的author信息设置为指定的名字和邮箱。然后在git push时,这个commit的author信息也会一起被推送到remote仓库。
    例如:

    git commit --author=“张三 zhangsan@example.com” -m “commit message”

    push时author信息也会带上

    git push origin master

    如果要修改最近的commit的author信息,可以使用amend选项:

    git commit --amend --author=“李四 lisi@example.com” --no-edit

    这会修改最近一次commit的author信息,而不修改commit message。

    10.编写gitignore文件

    例如

    .gitignore
    /pycache
    model/

    ptuning-v2/*
    text_model/*
    txt_files/*
    XLGPT2/knowledge_base/*
    XLGPT2/logs/*
    *.pyc

    .gitignore 文件列出了一些规则,用来忽略版本控制中不需要的文件或目录。具体包含以下几个规则:

    1. /pycache
      忽略所有目录下的 pycache 文件夹,这是 Python 编译文件的缓存文件夹。
    2. model/
      忽略 model/ 这个文件夹。
    3. ptuning-v2/*
      忽略 ptuning-v2/ 目录下的所有内容。
    4. text_model/*
      忽略 text_model/ 目录下的所有内容。
    5. txt_files/*
      忽略 txt_files/ 目录下的所有内容。
    6. XLGPT2/knowledge_base/*
      忽略 XLGPT2/knowledge_base/ 目录下的所有内容。
    7. XLGPT2/logs/*
      忽略 XLGPT2/logs/ 目录下的所有内容。
    8. *.pyc
      忽略项目中所有的 .pyc 文件,这也是 Python 编译文件的扩展名。
      综上,这个 .gitignore 主要用于忽略 Python 和项目相关的临时文件、日志文件、已编译的字节码文件等无需版本控制的内容。使用 .gitignore 可以有效地减少无用提交,保持仓库的精简和干净。
  • 相关阅读:
    车载语音交互「停摆」
    用批处理连续ping一个ip段
    如何实现购物车一键全选?
    五、java代码实现快速排序
    IDA pro逆向工具寻找socket server的IP和port
    cmd 开放 8018端口 --chatGPT
    比特集训营第一课
    在uniapp和微信小程序中onshow和onload的区别
    RabbitMQ快速入门
    堪称一绝,这份70W年薪高并发架构技术分布式大量流限流PDF,再不会算我输
  • 原文地址:https://blog.csdn.net/qq128252/article/details/127120175