赞
踩
sudo apt-get install git
mkdir ~/git
cd ~/git
git config --global user.name "xxxx"
git config --global user.email "xxxx@xxx.com"
配置ssh
colamachine@ubuntu:~/git$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/colamachine/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/colamachine/.ssh/id_rsa.
Your public key has been saved in /home/colamachine/.ssh/id_rsa.pub.
The key fingerprint is:
xxxxxxxxxxxxxxxxxxxxx colamachine@ubuntu
The key's randomart image is:
xxxxxxxx
新创建的sshkey 记得添加到当前系统中
# ssh-add ~/.ssh/id_rsa
不然系统是不认可的
colamachine@ubuntu:~/git$ cat ~/.ssh/id_rsa.pub
将里面的公钥交给管理员,当然这里面我们是搭建了一个git私服,我们登陆内网git网站
http://192.168.1.1:8000/huashan-group/merchant-manage
输入用户名密码,profile setting->ssh Key ->add ssh key
把id_rsa.pub 里的内容拷贝进去
然后再命令行里输入
colamachine@ubuntu:~/git$ git clone git@192.168.10.147:huashan-group/merchant-manage.git
会弹出一个unlock ssh key 的输入框 ,输入 之前填写的密码
然后
Cloning into 'merchant-manage'...
The authenticity of host '192.168.10.147 (192.168.10.147)' can't be established.
RSA key fingerprint is aa:7d:d2:9a:41:36:e8:30:f0:a0:96:c6:2b:ec:83:e4.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.10.147' (RSA) to the list of known hosts.
remote: Counting objects: 3182, done.
remote: Compressing objects: 100% (2158/2158), done.
remote: Total 3182 (delta 1629), reused 1514 (delta 678)
Receiving objects: 100% (3182/3182), 49.12 MiB | 1.77 MiB/s, done.
Resolving deltas: 100% (1629/1629), done.
Checking connectivity... done.
下载完成
切入刚下载的目录
colamachine@ubuntu:~/git$ git branch
colamachine@ubuntu:~/git$ cd merchant-manage/
colamachine@ubuntu:~/git/merchant-manage$ ls
pom.xml src
colamachine@ubuntu:~/git/merchant-manage$ git branch
* master
colamachine@ubuntu:~/git/merchant-manage$ git remote
origin
但是由于目前我开发的项目是在dev分支上 所以我还得把dev分支down下来
olamachine@ubuntu:~/git/merchant-manage$ git checkout -b dev origin/dev
Branch dev set up to track remote branch dev from origin.
Switched to a new branch 'dev'
colamachine@ubuntu:~/git/merchant-manage$ git branch
* dev
master
现在我们就能用eclipse 在这个版本上开发了
重新ssh key gen 之后 发现有问题
現在的 ssh 使用同樣的方法會出現錯誤訊息
解決方式 使用 ssh-add 指令将私钥 加进来 (根据个人的密匙命名不同更改 id_rsa)
# ssh-add ~/.ssh/id_rsa
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。