github 命令使用

github 命令使用

1、一般流程

1.1 先下载文件
git clone https://github.com/xxxxxxxxxxx
1.2 指定分支
git clone -b +分支 + 地址
(或推送本地到远程仓库 git commit add origin htt…)
1.3 下载包括子模块
git clone --recursive https://github.com/xxxxxxxxxxx

2、配置用户信息
git config --local user.name “xxxx” #配置用户名
git config --local user.email “xxxxxxxx@qq.com” #配置用户邮箱
git config --local -l #查看配置结果
3、改完内容后,先上载缓存
git add .
并先定义修改主要内容
git commit -m ‘注释’ 提交添加的文件并备注说明
4、上传
git push
输入用户:
输入密码:

2、分支管理

2.1 分支切换和上传

查看状态

git status 	

查看变更日志

git log 

查看分支

git branch 

创建分支develop-xx

git branch develop-xx

切换当前分支

git checkout  develop-xx
//修改分支的内容后
//提交分支的内容
git add .
git commit -m "修改了XXXXX"
//在云端创建分支,并提交内容
git push --set-upstream origin develop-xx

上传修改develop-xx分支 将本地仓库文件推送到远程仓库develop-xx

git push -u origin  develop-xx

将远程仓库develop-xx分支内容更新到本地

git push  origin develop-xx 
2.2合并

git checkout develop-xx 切换到叫develop-xx的分支上
git merge develop-xx 把newname分支合并到当前分支上
git pull origin develop-xx 将develop-xx分支上的内容拉到本地上

git push -u origin develop-xx 将本分支上的内容上传到develop-xx分支
git push origin develop-xx 将本分支上的内容上传到develop-xx分支

一般情况下git pull某个分支之后,进行修改,再git push就会发到对应的某个分支上。
如果当前分支不是从远程git clone下来的,而是本地创建的分支或者其它分支,那么当进行push时,使用git push -u ,就会与该分支建立联系,下次再git push 就会直接默认当前分支。

2.3 子模块内容

下载全部子模块

git submodule update --init --recursive

下载指定子模块

git submodule update --init --recursive -- "navZero/workspace/src/mnl"

3、回退

1、git reset --mixed 版本号 :此为默认方式,不带任何参数的git reset,即时这种方式,它回退到某个版本,只保留源码,回退commit和index信息

本地工作目录内容以及暂存区内容保留

2、git reset --soft 版本号:回退到某个版本,只回退了commit的信息,不会恢复到index file一级。如果还要提交,直接commit即可

本地工作目录内容以及暂存区内容全部回退至某一个版本

3、git reset --hard 版本号:彻底回退到某个版本,本地的源码也会变为某个版本的内容

4、git push 遇到问题

问题1
Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.

因为没有

git add .
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值