在提交代码时,git如何忽略指定文件

在提交代码时,git如何忽略指定文件

当用git向github上传本地代码时,有时需要忽略一些本地某些文件如:node_modules或webStorm自动生成的.idea文件,只需要修改当前项目的根目录中的.gitignore,将要忽略的文件加入到此文本中。如下所示:

.idea/
node_modules/
logs/
.svn
*.iml
npm-debug.log

删除远程分支

git push origin :分支名

例如:要删除远程服务器上面的bugfix分支就可以用git push origin :bugfix

删除本地分支

git branch -d 分支名

例如:要删除本地的bugfix分支,要首先跳转到非bugfix分支上面,然后运用git branch -d bugfix

怎样修改默认上传分支

当运用git push上传代码时出现如下错误时:

fatal: The upstream branch of your current branch does not match
the name of your current branch.  To push to the upstream branch
on the remote, use

    git push origin HEAD:upgrade-201708

To push to the branch of the same name on the remote, use

    git push origin v2.0-bugfix

To choose either option permanently, see push.default in 'git help config'.

可以通过设置默认值进行修正:git config --global push.default matching

  • nothing: 意思是当git push 不上传任何东西。
  • matching: 上传所有可以匹配的分支代码,即本地分支和远程分支相同时所有的代码。
  • upstream: 上传当前分支代码到它的上游分支上面。
  • current: 上传当前分支代码到远程同名分支上面。
  • simple: 和upstream具有相同的功能,但当上游分支名和当前分支名不一样时就会报错
查看本地配置

git config --global push.default

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值