美文网首页
git仓库操作方法管理

git仓库操作方法管理

作者: lookphp | 来源:发表于2018-06-26 11:04 被阅读20次

1、初始化生成公钥

ssh-keygen -t rsa -C "youremail@example.com"

2、配置用户名邮箱

当前仓库配置:

git config user.name "Your Name"
git config user.email "email@example.com"

全局配置:

git config --global user.name "Your Name"
git config --global user.email "email@example.com"

3、查看配置信息

查看系统config
git config --system --list

查看当前用户(global)配置
git config --global --list

查看当前仓库配置信息
git config --local --list

4、添加远程仓库

文件夹存在的时候,新建仓库并添加远程仓库:

cd existing_folder
git init
git remote add origin git@xxx.xxx.xxx.xxx:Project/service.git
git add .
git commit
git push -u origin master

仓库存在的时候,添加远程仓库:

cd existing_repo
git remote add origin git@xxx.xxx.xxx.xxx:Project/service.git
git push -u origin --all
git push -u origin --tags

5、修改提交模板git_template

git config commit.template [模板文件名]    //这个命令只能设置当前分支的提交模板
git config commit.template git_template 

git config --global commit.template [模板文件名]    //这个命令能设置全局的提交模板,注意global前面是两杠 
git config --global commit.template git_template

6、no matching key exchange method found算法不匹配提示解决方案

问题提示:

Unable to negotiate with 192.168.4.28 port 19428: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

解决方案:

  • 1、修改ssh config文件

windows:

cd ~/.ssh/
vim config

linux:

/etc/ssh/ssh_config
vim ssh_config
  • 2、修改config文件内容,如下:
Host *.*.*.*  
    KexAlgorithms +diffie-hellman-group1-sha1
  • 3、再次执行 git clone xxx.git,即可执行成功。

---------------------------------------------------分割线------------------------------------------------------

7、gerrit change-id第一次提交时不成功的解决办法

  • 1、根据提示:复制提示中的gitdir=$(git rev-parse --git-dir); scp -p -P 29418 user@xxx.xxx.xxx.xxx:hooks/commit-msg ${gitdir}/hooks/到命令行,并点击回车执行。
  • 2、执行git commit --amend命令,重新commit提交代码
  • 3、执行git push命令,上传代码到服务器即可
>gitdir=$(git rev-parse --git-dir); scp -p -P 29418 user@xxx.xxx.xxx.xxx:hooks/commit-msg ${gitdir}/hooks/
>git commit --amend

相关文章

  • git仓库操作方法管理

    1、初始化生成公钥 2、配置用户名邮箱 当前仓库配置: 全局配置: 3、查看配置信息 4、添加远程仓库 文件夹存在...

  • git常用命令

    git config //配置详细 git init //初始化仓库 git remote //管理远程仓库 添加...

  • Git Note

    创建Git项目 创建仓库目录mkdir dir 初始化仓库git init Git文件管理 把文件加入仓库git ...

  • Git 分支管理规范

    Git 仓库申请流程 开发主管向 Git 管理员提交 Git 仓库申请【邮件:发送给 Git 管理员,抄送给项目经...

  • Git常用指令记录

    git init 这个目录变成Git可以管理的仓库 git status 查看当前仓库状态 git diff re...

  • git常用命令

    git init 把当前目录变成git可以管理的仓库 git clone <地址> 克隆远程仓库 git br...

  • git分支管理规范

    Git 仓库申请流程 1. 开发主管向Git 管理员提交Git 仓库申请【邮件:发送给Git 管理员,抄送给项目经...

  • GitHub超简单小白入门详细教程(11)——使用Git管理远程

    使用Git管理远程仓库 使用远程仓库的目的 作用:备份,实现代码共享集中化管理 Git克隆操作 目的:将远程仓库(...

  • Git学习笔记

    基础命令 git init 把目录变成Git可以管理的仓库。 git add 把文件添加到仓库。 git comm...

  • Git- 本文还在更新中

    仓库的创建 将目录变成Git可以管理的仓库git init 在当前仓库创建一个文件 将该文件添加到仓库中 git ...

网友评论

      本文标题:git仓库操作方法管理

      本文链接:https://www.haomeiwen.com/subject/hxupyftx.html