首页 技术 正文
技术 2022年11月21日
0 收藏 320 点赞 3,689 浏览 1197 个字

1.将本地与github进行关联配置

生成公钥

ssh-keygen -t rsa -C "jiasheng.mei@hpe.com"

将公钥拷贝到github中

在公钥同文件夹(.ssh)下创建config文件,文件内容

Host ssh.github.com
User git
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443

生成公钥后将公钥配置到github上

将github上的项目clone到本地

git clone git@github.com:jiashengp/test.git

在本地init一个git项目

git init

修改了文件后添加

git add .

commit并写commit注释

git commit -m "commit text"

将本地和github库关联

git remote add origin git@github.com:jiashengp/test.git

如果出现fatal: remote origin already exists.则直接进行下面语句

git push origin master

给你的队友创建一个分支

  1. git branch cjun
  2. git add .
  3. git commit -m "Create cjun branch give chengjun"

同步到github上

  1. git push -u origin cjun

这时你可以在github上看到为队友创建的分支

查看分支:git branch

切换分支:git checkout newBranch

你的队友在github上改了readme.md,你需要同步到本地的git仓库

将github上cjun分支的下载到临时的分支temp

  1. git fetch origin cjun:temp

看下同一个文件你和你的队友有啥区别

  1. git diff temp (在那个分支下,就是这个分支和temp比较)

合并temp分支到本地的master分支(也可以是其他分支)

  1. git merge temp

把临时分支干掉

  1. git branch -D temp

其实上面等价:

git pull origin cjun:temp

如果是远程分支(cjun)与当前所在分支合并

git pull origin cjun

$ git checkout Zhaozheng

$ vi readme.md

$ git commit -m "change readme.md use branch zhaozheng"

$ git checkout master

$ git merge Zhaozheng

$ cat readme.md

从github上更新,本地修改并最终同步到github

$ cat README.md

$ git pull origin master

$ clear

$ vi README.md

$ git add .

$ git commit -m "testgit2 commit third"

$ git push origin master

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,962
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,486
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,331
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,114
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,747
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,781