Discuz! Board

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1615|回复: 3
打印 上一主题 下一主题

win7下同步github上的代码

[复制链接]

8

主题

12

帖子

62

积分

认证用户组

Rank: 5Rank: 5

积分
62
跳转到指定楼层
楼主
发表于 2018-10-15 19:54:05 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 vue 于 2018-10-15 20:36 编辑

先安装完 git
找到要同步代码的目录 ,右键->git Bash Here

默认账号设置的是全局账号,可用如下命令查询:
git config --global --get user.name
git config --global --get user.email
一般默认是公司账号,git上的账号单独配置

因此要创建不同的公钥:
ssh-keygen -t rsa -b 4096 -C "chunhuitech@hotmail.com" -f id_rsa_github_chkj-hotmail.com
根据提示输入密码 XXXXX

默认生成到 ~/.ssh/下,有如下两个文件

id_rsa_github_chkj-hotmail.com
id_rsa_github_chkj-hotmail.com.pub  把这个文件中的内容复制到github上

Settings->SSH and GPG keys -> New SSH key

修改 ~/.ssh/config
多添加个ssh配置
# Personal GitHub
Host chkj.hotmail.com
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa_github_chkj-hotmail.com

测试配置
使用如下命令,检查之前的配置是否正确:
    $ ssh -T git@chkj.hotmail.com
    Hi hechengjin! You've successfully authenticated, but GitHub does not provide shell access.
clone代码时要注意:
git clone git@github.com:user1/proj1.git  一定要把git@github.com改成 git@chkj.hotmail.com
然后输入 相应密码就可以了





回复

使用道具 举报

697

主题

1142

帖子

4086

积分

认证用户组

Rank: 5Rank: 5

积分
4086
沙发
发表于 2019-2-2 16:57:44 | 只看该作者
以https(用户名密码)方式同步代码
git clone https://github.com/xxx/shell.git
...
git commit
git push -u origin master

在此之前先要设置
git config --global user.email "you@example.com"
  git config --global user.name "Your Name"



回复 支持 反对

使用道具 举报

9

主题

15

帖子

103

积分

认证用户组

Rank: 5Rank: 5

积分
103
板凳
发表于 2019-3-6 19:37:17 | 只看该作者
安装git


右键->git Bash Here
进入 cd ~ 然后创建.ssh目录
mkdir .ssh
进入 .ssh
cd .ssh
执行 ssh-keygen -t rsa -b 4096 -C "chunhuitech@hotmail.com" -f id_rsa_github_chunhuitech.com
把生成的 id_rsa_github_chunhuitech.com.pub 里面的内容复制到github上
修改 ~/.ssh/config
多添加个ssh配置
# Personal GitHub
Host chkj.hotmail.com
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa_github_chunhuitech.com


测试配置
使用如下命令,检查之前的配置是否正确:
    $ ssh -T git@chkj.hotmail.com
    Hi hechengjin! You've successfully authenticated, but GitHub does not provide shell access.
clone代码时要注意:
git clone git@github.com:user1/proj1.git  一定要把git@github.com改成 git@chkj.hotmail.com
然后输入 相应密码就可以了







回复 支持 反对

使用道具 举报

1228

主题

1997

帖子

7582

积分

认证用户组

Rank: 5Rank: 5

积分
7582
地板
发表于 2019-12-28 19:02:03 | 只看该作者
本帖最后由 Qter 于 2020-1-12 12:40 编辑

如果只有一个项目,可用下面方法设置一个全局账号:
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
设置完后,用如下命令查看:
git config --global --get user.name
git config --global --get user.email

针对项目设置账号:
git config --local user.email "xxx@xxx.com"
git config --local user.name "xxx"



Git - git config 查看配置信息前言

    git 中通过 git config查看配置信息
    config 配置有system级别 global(用户级别) 和local(当前仓库)三个
    设置先从system -》global -》local 底层配置会覆盖顶层配置 分别使用–system/global/local 可以定位到配置文件

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

相关路径:'C:\Program Files\Git\mingw64/etc/gitconfig'

查看当前用户(global)配置

git config --global  --list

查看当前仓库配置信息

git config --local  --list

core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
remote.origin.url=git@chkj.hotmail.com:chunhuitech/ch-web-ch.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|firemail ( 粤ICP备15085507号-1 )

GMT+8, 2024-5-2 13:27 , Processed in 0.062326 second(s), 18 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表