gitHub创建分支出现错误【git常见问题】fatal: Not a valid object name: 'master'.

本文介绍了一种常见的Git操作问题——无法创建名为dev的本地分支,并给出了详细的解决步骤。问题源于本地尚未创建master分支,解决方案是在本地仓库中添加一个文件以创建master分支,之后即可顺利创建dev分支。

创建本地分支:git branch dev

报错:fatal: Not a valid object name: 'master'.

 

原因:

 问题描述-一个非法的master,原因:本地还没有创建master,你可以执行以下git branch,会发现没有看到本地分支列表

解决方案:

  如果本地没有文件,添加一个文件

此时本地仓库主干master 创建成功,使用git branch 查看本地分支列表,会查看到如下图所示

可以创建本地分支:

 git branch dev

[root@yfw ~]# cd /www/wwwroot/szrengjing.com/jsxc/jsxc-master [root@yfw jsxc-master]# cd /www/wwwroot/szrengjing.com/jsxc/jsxc-master [root@yfw jsxc-master]# [root@yfw jsxc-master]# # 初始化 git 仓库 [root@yfw jsxc-master]# sudo -u www git init Initialized empty Git repository in /www/wwwroot/szrengjing.com/jsxc/jsxc-master/.git/ [root@yfw jsxc-master]# sudo -u www git add . [root@yfw jsxc-master]# sudo -u www git commit -m "Initial commit for build" *** Please tell me who you are. Run git config --global user.email "you@example.com" git config --global user.name "Your Name" to set your account's default identity. Omit --global to set the identity only in this repository. fatal: empty ident name (for <www@yfw.szrengjing.com>) not allowed [root@yfw jsxc-master]# npm list git-revision-webpack-plugin @jsxc/jsxc@4.4.0 /www/wwwroot/szrengjing.com/jsxc/jsxc-master └── git-revision-webpack-plugin@3.0.6 [root@yfw jsxc-master]# sudo -u www yarn build yarn run v1.22.22 warning ../../package.json: No license field $ webpack --progress --config webpack.config.js --mode production fatal: Not a valid object name HEAD [webpack-cli] Failed to load '/www/wwwroot/szrengjing.com/jsxc/jsxc-master/webpack.config.js' config [webpack-cli] Error: Command failed: git describe --always fatal: Not a valid object name HEAD at checkExecSyncError (child_process.js:635:11) at execSync (child_process.js:671:15) at module.exports (/www/wwwroot/szrengjing.com/jsxc/jsxc-master/node_modules/git-revision-webpack-plugin/lib/helpers/run-git-command.js:25:34) at GitRevisionPlugin.version (/www/wwwroot/szrengjing.com/jsxc/jsxc-master/node_modules/git-revision-webpack-plugin/lib/index.js:65:10) at Object.<anonymous> (/www/wwwroot/szrengjing.com/jsxc/jsxc-master/webpack.config.js:52:85) at Module._compile (internal/modules/cjs/loader.js:999:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) at Module.load (internal/modules/cjs/loader.js:863:32) at Function.Module._load (internal/modules/cjs/loader.js:708:14) at Module.require (internal/modules/cjs/loader.js:887:19) { status: 128, signal: null, output: [ null, <Buffer >, <Buffer 66 61 74 61 6c 3a 20 4e 6f 74 20 61 20 76 61 6c 69 64 20 6f 62 6a 65 63 74 20 6e 61 6d 65 20 48 45 41 44 0a> ], pid: 647253, stdout: <Buffer >, stderr: <Buffer 66 61 74 61 6c 3a 20 4e 6f 74 20 61 20 76 61 6c 69 64 20 6f 62 6a 65 63 74 20 6e 61 6d 65 20 48 45 41 44 0a> } error Command failed with exit code 2. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. [root@yfw jsxc-master]# sudo -u www yarn build --bundleAnalyzer yarn run v1.22.22 warning ../../package.json: No license field $ webpack --progress --config webpack.config.js --mode production --bundleAnalyzer [webpack-cli] Error: Unknown option '--bundleAnalyzer' [webpack-cli] Run 'webpack --help' to see available commands and options error Command failed with exit code 2. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. [root@yfw jsxc-master]#
最新发布
11-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值