Git创建分支并推送到服务器具体步骤
2017-08-15 14:07
337 查看
Last login: Thursday 2017-08-03 15:36:00
初始化git
git init
查看本地分支:
git branch -a
* master
切换到本地新建的分支:
git checkout develop
查看本地分支:
git branch -a
添加文件本地暂存空间
git add .
提交到本地仓库
git commit -m 'develop branch'
The authenticity of host '<serverIP> (<ServerIP>)' can't be established.
ECDSA key fingerprint is SHA256:4iz8GeaeyVQwOUosf95NgKC/TnZEltJNdTM0F6Bx1ko.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'serverIP' (xxx) to the list of known hosts.
git@gitserverIP's password:
Permission denied, please try again.
Generating public/private rsa key pair.
Enter file in which to save the key
(/Users/xxx/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/xxx/.ssh/id_rsa.
Your public key has been saved in /Users/xxx/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:/xGIikiH0MzxNeyXj2g61mJTmGeKYMFvc481o9Frkjs
sample@email.com
The key's randomart image is:
+---[RSA 2048]----+
| . .o |
| + o ... |
|o + .. . |
| + . . o. . |
| = .o.oSo. . |
|.o *o+**... . |
|..o.+OO + . . |
| . OE.+ . . |
| o == . |
+----[SHA256]-----+
MacBook-Air:xxx xxx$ open ~/.ssh/
直接在文件夹里用文本编辑打开文件:id_rsa.pub
将里面的内容粘贴在服务器上的SSH key里面命名key的名字并点击添加
检查是否添加成功:
ssh -T git@<gitServerIP>
显示下面的信息就表示成功了:Welcome to Git, Sample!
下面的配置,一次配置完后面不用每次输入用户名密码:
git config --global user.name "xxx"
git config --global user.email "[b]sample@email.com[b]"[/b][/b]
Counting objects: 267, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (259/259), done.
Writing objects: 100% (267/267), 43.50 MiB | 13.74 MiB/s, done.
Total 267 (delta 149), reused 0
(delta 0)
remote: Resolving deltas: 100% (149/149), done.
remote:
remote: To create a merge request for develop, visit:
remote: http://gitServerIP/group/projectname/merge_requests/new?merge_request%5Bsource_branch%5D=develop remote:
To gitserverIP:group/project
* [new branch]
develop -> develop
切换到要同步的目录下面
cd /Desktop/project初始化git
git init
查看本地分支:
git branch -a
* master
创建本地新分支:
git branch develop切换到本地新建的分支:
git checkout develop
查看本地分支:
git branch -a
添加文件本地暂存空间
git add .
提交到本地仓库
git commit -m 'develop branch'
尝试推送到远程仓库失败:没有创建SSH密钥
git push git@xx.xx.xx.xxx:xxx/xxxx develop:developThe authenticity of host '<serverIP> (<ServerIP>)' can't be established.
ECDSA key fingerprint is SHA256:4iz8GeaeyVQwOUosf95NgKC/TnZEltJNdTM0F6Bx1ko.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'serverIP' (xxx) to the list of known hosts.
git@gitserverIP's password:
Permission denied, please try again.
创建本地密钥:
ssh-keygen -t rsa -C "sample@email.com"Generating public/private rsa key pair.
Enter file in which to save the key
(/Users/xxx/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/xxx/.ssh/id_rsa.
Your public key has been saved in /Users/xxx/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:/xGIikiH0MzxNeyXj2g61mJTmGeKYMFvc481o9Frkjs
sample@email.com
The key's randomart image is:
+---[RSA 2048]----+
| . .o |
| + o ... |
|o + .. . |
| + . . o. . |
| = .o.oSo. . |
|.o *o+**... . |
|..o.+OO + . . |
| . OE.+ . . |
| o == . |
+----[SHA256]-----+
MacBook-Air:xxx xxx$ open ~/.ssh/
直接在文件夹里用文本编辑打开文件:id_rsa.pub
将里面的内容粘贴在服务器上的SSH key里面命名key的名字并点击添加
检查是否添加成功:
ssh -T git@<gitServerIP>
显示下面的信息就表示成功了:Welcome to Git, Sample!
下面的配置,一次配置完后面不用每次输入用户名密码:
git config --global user.name "xxx"
git config --global user.email "[b]sample@email.com[b]"[/b][/b]
再次尝试推送本地仓库的分支到远程仓库:
git push git@<gitServerIP>:<group>/<project> develop:developCounting objects: 267, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (259/259), done.
Writing objects: 100% (267/267), 43.50 MiB | 13.74 MiB/s, done.
Total 267 (delta 149), reused 0
(delta 0)
remote: Resolving deltas: 100% (149/149), done.
remote:
remote: To create a merge request for develop, visit:
remote: http://gitServerIP/group/projectname/merge_requests/new?merge_request%5Bsource_branch%5D=develop remote:
To gitserverIP:group/project
* [new branch]
develop -> develop
相关文章推荐
- Git创建分支并推送到远程服务器
- git 创建本地分支,然后推送到服务器上
- 推送现有git到远程服务器并创建新分支
- 推送现有git到远程服务器并创建新分支
- git 本地库的创建以及如何完成服务器仓库的分支的映射和同步
- git 从远程主服务器当中创建新分支
- Git创建远程分支步骤
- git 远程分支创建与推送
- Git 创建分支+分支推送+本地切换远程分支+免密码git操作
- 从gitflow 用gitbash创建一个分支并且推送到远程命令行
- git 远程分支创建与推送
- git 远程分支创建与推送
- git分支创建并上传到服务器和从服务器下载分支代码
- git本地创建新分支并推送到远程仓库
- git 远程分支创建与推送
- 创建Git新分支步骤
- git 远程分支创建与推送
- git 远程分支创建与推送
- git远程分支创建和推送【转载】
- git 查看远程分支、本地分支、创建分支、推送分支到远程repository、获取远程分支、删除本地、远程分支