git命令整理

1、代码提交

git add .
git commit -m '注释信息'
git push origin [branch]

 

1、删除远程分支

git push origin --delete [branchName]

2、仓库迁移,详情参考:https://developer.atlassian.com/blog/2016/01/totw-copying-a-full-git-repo/

git clone [url to ORI repo] [temp-dir]
cd [temp-dir]
// <!-- 检查所有分支 -->
git branch -a
git checkout [branch-name]
git fetch --tags
git tag
git branch -a
git remote rm origin
git remote add origin [url to NEW repo]
git push origin --all
git push --tags

3、版本回退

    1)查看git从最近到最远的提交日志

git log

git log --pertty=oneline  // (输出信息比git log精简)

// 输出示例1
    192:Vue-Framework yee$ git log
    commit 3e919fe3ad448847017a430e2b0036e6c71c2d29 (HEAD -> webpack4, origin/master, typescript, master)
    Author: wangjieyee <wangjieyee@163.com>
    Date:   Thu May 30 15:01:30 2019 +0800

        配置dev多个环境

    commit f582ff9df3138e0270e1d590ee51a3c39b9f939b
    Author: wangjieyee <wangjieyee@163.com>
    Date:   Tue Mar 5 16:15:44 2019 +0800

        升级webpack4

    commit db9e0b246d4baeb486d3e018f5373155769c9f26
    Author: wangjieyee <wangjieyee@163.com>
    Date:   Mon Apr 2 17:13:47 2018 +0800

        project init

    commit d0ece0a742897ed6e268d7207e593ecbb1bc2fff
    Author: wangjieyee <wangjieyee@163.com>
    Date:   Mon Mar 5 11:49:45 2018 +0800

        vue product init

    // 输出示例2
    192:Vue-Framework yee$ git log --pretty=oneline
    3e919fe3ad448847017a430e2b0036e6c71c2d29 (HEAD -> webpack4, origin/master, typescript, master) 配置dev多个环境
    f582ff9df3138e0270e1d590ee51a3c39b9f939b 升级webpack4
    db9e0b246d4baeb486d3e018f5373155769c9f26 project init
    d0ece0a742897ed6e268d7207e593ecbb1bc2fff vue product init

    2)commit后面的是对应的版本号

git reset --hard f582ff9df3138e0270e1d590ee51a3c39b9f939b

    

    3)强行推送至服务器端

git push --force

 

 4、删除缓存的远程分支列表

git remote prune origin


git fetch -p

5、git fork 

A仓库:https://github.com/A/project

(1)fork

1) 进入A的git仓库点击fork按钮,在自己的github上得到一个fork:https://github.com/B/project

2)git clone https://github.com/B/project

3)cd project

4)为A项目命名,方便与A项目互相联系:git remote add upstream https://github.com/A/project。此处将A项目命名为upstream。

(2)更新

1)更新A项目(但是不会更新B的文件):git fetch upstream 

2)将更新到的代码合并到B:git merge upstream/master

(3)提交

1)先提交至B仓库,参考上文

2)进入B的github:https://github.com/B/project

a.点击Pu'll requests

b.点击new pull request

c.点击created pull request

d.输入title和content

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值