github在ubuntu下使用教程

1.安装git

sudo apt get install git

2.然后在src文件夹中初始化git仓库

git init

3.  配置提交代码时的用户信息:

     git config --global user.email 573705543@qq.com

     git config --global user.name"haigujiujian"

home 目录下会生成一个.gitconfig

4.为github账号添加ssh秘钥

sudo apt-get install openssh-server openssh-client

sudo /etc/init.d/ssh restart

生成秘钥:ssh-keygen -C '573705543@qq.com' -t rsa

 ssh -v git@github.com

cat ~/.ssh/id_rsa.pub获取秘钥

添加秘钥到上面的SSH and GPG KEYS到github的SSH and GPG keys里面

将本地仓库关联到GitHub新建的仓库上:

git remote add origin https://github.com/Love-LG/Javaweb-firstcup-war

当然也可以更换仓库 git remote rm origin 就可以了

然后就是git add *

git commit -m " first commit"

然后就可以 git push origin master

ssh -T git@github.com 可以用于检测与github仓库是否已经连接上

git新建分支并提交本地代码到远程分支

  step1,在本地新建分支

      git branch newbranch

  step2:把本地分支push到远程

    git push origin newbranch

  step3:切换到该分支

    git checkout newbranch

  step4:查看本地修改

    git status

  step5:添加本地修改

    git add .

  step6:commit修改

    git commit -m 'XXXX'

   step7:push代码

    git push

 

 

 

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值