1、mac安装
查看git
git --version
默认有安装
2、配置(命令行操作服务器)
mac创建本地创建本地ssh-key,远程代码库服务器地址:192.168.2.10
ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/tangscott/.ssh/id_rsa):
/Users/tangscott/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/tangscott/.ssh/id_rsa.
Your public key has been saved in /Users/tangscott/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:Dw+4NhdJK5eWi3MAdbIzoiqnG9sBrs+PmXTFqzeTI14 tangscott@tangscottdeMacBook-Air.local
The key's randomart image is:
+---[RSA 2048]----+
| o . |
| . + |
| o + . |
| . + = = |
|. . * S |
|.o . O B |
|+.+ . E.+ o |
|oO *.+*= |
|=oBo+o + |
+----[SHA256]-----+
上传密钥文件 id_rsa.pub到代码服务器
cat /Users/tangscott/.ssh/id_rsa.pub | ssh git@192.168.2.10 "cat >> ~/.ssh/authorized_keys"
如果服务器/home/git/.ssh/authorized_keys不存在,在服务器上使用
ssh-keygen -t rsa 运行,一直回车即可
添加全局变量(暂时不用)
$ git config –-global user.name ‘yourName’
$ git config –-global user.email ’yourEmail@yourEmail.com‘
客户端命令行输入:git clone git@192.168.2.10:/usr/local/javasoft/gitrepos/flysky.git
git clone git@192.168.2.10:/usr/local/javasoft/gitrepos/flysky.git
Cloning into 'flysky'...
git@192.168.2.10's password:
warning: You appear to have cloned an empty repository.
3、idea配置,操作git
项目提交
本地仓库,在弹框选择要提交的项目,点击ok
在git服务器上创建一个同名项目
cd /usr/local/javasoft/gitrepos
初始化一个仓库名称为flysky
git init --bare flysky-parent.git
项目名称右键,选择git-->add;再项目名称右键,选择git-->commit
选择 git-->add 文件进入暂存区,选择 git-->commit 文件进入版本库
在弹框,点击“define remote”,输入git服务器地址,点击push即可
git@192.168.2.10:/usr/local/javasoft/gitrepos/flysky-parent.git
从服务器上面clone
最后在192.168.2.10:/usr/local/javasoft/gitrepos/flysky-parent.git目录里面没有找到工程的相关文件。。。。。。。。