git从版本库创建、从远程克隆或本地新建,配置KEY,合并分支到提交到远程版本库等步骤
来源:互联网 发布:java程序设计基础 编辑:程序博客网 时间:2024/06/10 11:21
首先配置自己的用户名和邮箱
[root@centos http]# git config --global user.name "lining"[root@centos http]# git config --global user.email "lining@orgtec.cn"
再创建新的KEY,如果有的话就直接跳过到下面的正式创建步骤:
ssh-keygen -t rsa -C "your_email@youremail.com"Creates a new ssh key using the provided email Generating public/private rsa key pair.#此处输入将要保存的路径,默认为当前路径Enter file in which to save the key (/Users/your_user_directory/.ssh/id_rsa):<press enter>输入回车后提示输入一个类似于密码的自定义的通行证号,如果直接回车则为空Enter passphrase (empty for no passphrase):<enter a passphrase>#提示重新输入以便确认输入是否正确Enter same passphrase again:<enter passphrase again>然后进入目录.ssh[root@centos .ssh]# cd ~/.ssh[root@centos .ssh]# ll总用量 24-rw-------. 1 root root 1743 1月 30 15:29 135790-rw-r--r--. 1 root root 399 1月 30 15:29 135790.pub-rw-------. 1 root root 1743 1月 30 15:43 id_rsa-rw-r--r--. 1 root root 398 1月 30 15:43 id_rsa.pub-rw-r--r--. 1 root root 4727 10月 9 18:09 known_hosts[root@centos .ssh]# vi id_rsa.pub
这里面的就是生成的KEY,把它复制到github上的配置里面就OK了。
正式创建:
1、
创建一个新的文件夹:
[root@centos http]# mkdir activityTestLee
2、
进入该文件夹
cd activityTestLee
3、
创建本地版本库:
[root@centos activityTestLee]# git initInitialized empty Git repository in /http/activityTestLee/.git/
4、
从远程版本库进行克隆(相当于建立了一个链表,并没有把代码从上面copy到本地):
[root@centos activityTestLee]# git clone ssh://lining@ip:8849/activityInitialized empty Git repository in /http/activityTestLee/activity/.git/Enter passphrase for key '/root/.ssh/id_rsa':remote: Counting objects: 3082, doneremote: Finding sources: 100% (3082/3082)remote: Total 3082 (delta 1140), reused 3031 (delta 1140)Receiving objects: 100% (3082/3082), 13.35 MiB | 670 KiB/s, done.Resolving deltas: 100% (1140/1140), done.
5、
获取钩子:
[root@centos activityTestLee]# scp -p -P 8849 lining@ip:hooks/commit-msg .git/hooks/Enter passphrase for key '/root/.ssh/id_rsa':commit-msg 100% 4365 4.3KB/s 00:00
6、
查看当前从远程版本库获取的东西
[root@centos activityTestLee]# lsactivity
注:当前从远程版本库获取的activity下面只有一个.git文件,其他的要等在本地创建分支之后才会出现。
7、
进入到文件下面:
[root@centos activityTestLee]# cd activity
8、
查看当前服务器和本地的所有分支:
[root@centos activity]# git branch -al* master remotes/origin/HEAD -> origin/master remotes/origin/develop remotes/origin/huodong remotes/origin/master remotes/origin/production
9、
创建本地分支develop并从远程版本库分支上面获取内容(现在本地有代码了)
[root@centos activity]# git checkout -b develop origin/developBranch develop set up to track remote branch develop from origin.Switched to a new branch 'develop'
10、
查看有哪些文件:
[root@centos activity]# lsdb deploy description.txt docs env_conf tools web
对本地所建分支的代码进行更改之后要进行如下操作提交到远程版本库:
11、添加到缓存区:
git add <filename>
12、提交到本地版本库
git commit -m "代码提交信息"
13、
获取远程版本库最新代码到本地远程版本库
git fetch
14、
将分支develop合并到当前的分支
git merge develop
15、
如果有冲突可以用rebase(这是一个过程)解决冲突
git rebase origin/develop
16、推送到版本库:
推到本地版本库:
git push origin master
推到本地版本库:
git push origin HEAD:refs/for/develop
大致步骤如下:
$ makdir ~/hello-world //创建一个项目hello-world $ cd ~/hello-world //打开这个项目 $ git init //初始化 $ touch README $ git add README //更新README文件 $ git commit -m 'first commit' //提交更新,并注释信息“first commit” $ git remote add origin git@github.com:defnngj/hello-world.git //连接远程github项目 $ git push -u origin master //将本地项目更新到github项目上去
其实,可以从第四步开始,然后5-6-7-8-9-10
给大家推荐一个我学习学习git的网址:http://gitref.org/zh/,希望可以通过我的分享帮助更多的人,也希望有更多的人出来分享,发扬互联网的开放精神。
0 0
- git从版本库创建、从远程克隆或本地新建,配置KEY,合并分支到提交到远程版本库等步骤
- Git从创建到推送到远程版本库
- git拉取远程分支并创建本地分支和Git中从远程的分支获取最新的版本到本地
- git拉取远程分支并创建本地分支和Git中从远程的分支获取最新的版本到本地
- git拉取远程分支并创建本地分支和Git中从远程的分支获取最新的版本到本地
- git - Git中从远程的分支获取最新的版本到本地方式
- Git中从远程的分支获取最新的版本到本地
- Git从远程的分支获取最新的版本到本地
- Git中从远程的分支获取最新的版本到本地方式如下
- git中从远程的分支获取最新的版本到本地
- 【收藏】git如何从远程分支获取最新版本到本地
- Git fetch/pull 从远程的分支获取最新的版本到本地
- git提交到远程版本库失败
- Git 将本地新建的分支提交到远程仓库
- git 创建本地分支、提交到远程分支
- git提交本地分支到远程分支
- git 本地分支提交到远程分支
- git clone从远程主机克隆一个版本库
- Json转对象失败:"No suitable constructor found for type [simple type, class com.test.faster.domain.respons
- 为iOS项目添加Daily Build
- Android性能调优
- webservice5j
- bwareaopen
- git从版本库创建、从远程克隆或本地新建,配置KEY,合并分支到提交到远程版本库等步骤
- LinearAlloc exceeded capacity Problem
- php-search_interpolation
- 【Android】调用系统图库获取图像并裁剪,安卓 4.4可用
- java 关键字volatile的作用
- 通过Itext生成PDF实例-操作超全
- JAVA和C++的主要区别有那些?
- html中嵌入flash
- Android中的wifi 概述