linux如何配置git

linux如何配置git,第1张

做前端的在日常工作中少不了和git打交道,那么新安装git之后使用webstorm进行项目上传时有时会出现只能创建项目无法上传文件的错误,那么这种错误是怎么形成的呢,原来是我们没哟成功配置git。按照下面的方式去做就可以解决这个问题。

首先确保自己已经安装了git,打开终端,运行:

查看当前git版本,如果没有安装运行:

sudo npm install git -g

进行git的安装。

运行如下命令对git用户的用户名和邮箱进行配置。

之后再进行上传发现问题已经解决。

1、环境准备

服务器:CentOS 7.3 + git (1.8.3.1)

客户端:win10 + git (2.17.0.windows.1)

2、服务器安装git

yum install -y git 

3、创建git用户,管理 git服务

[root@localhost home]# useradd git

[root@localhost home]# passwd git

4、服务器创建git 仓库

设置/home/git/repository-git 为git 服务器仓库,然后把 git 仓库的 owner 修改为 git 用户。

复制代码

[root@localhost git]# mkdir repository-git

[root@localhost git]# git init --bare repository-git/

Initialized empty Git repository in /home/git/repository-gt/

[root@localhost git]# chown -R git:git repository-git/

5、客户端安装git

下载 Git for Windows,地址:https://git-for-windows.github.io/

安装完之后,可以使用 Git Bash 作为命令行客户端。

5.1、选择一个目录 F:\project\sell 作为本地仓库,右键进入Git Bash 命令行模式

初始化本地仓库:git init

5.2、尝试克隆一个服务器的空仓库到本地仓库

git clone git@192.168.116.129:/home/git/repository-gt

第一次连接到目标 Git 服务器时会得到一个提示:

The authenticity of host '192.168.116.129(192.168.116.129)' can't be established.

RSA key fingerprint is SHA256:Ve6WV/SCA059EqoUOzbFoZdfmMh3B259nigfmvdadqQ.

Are you sure you want to continue connecting (yes/no)?

选择 yes:

Warning: Permanently added '192.168.116.129' (RSA) to the list of known hosts.

此时 C:\Users\用户名\.ssh 下会多出一个文件 known_hosts,以后在这台电脑上再次连接目标 Git 服务器时不会再提示上面的语句。


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/7539266.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-06
下一篇2023-04-06

发表评论

登录后才能评论

评论列表(0条)

    保存