我的项目中有一个master分支和一个searchfeature分支.我已将searchfeature分支推送到远程存储库,到目前为止一切正常
当我今天早上在那个分支上工作时,我做了"git push"我得到了以下内容:
warning: You did not specify any refspecs to push, and the current remote
warning: has not configured any push refspecs. The default action in this
warning: case is to push all matching refspecs, that is, all branches
warning: that exist both locally and remotely will be updated. This may
warning: not necessarily be what you want to happen.
warning:
warning: You can specify what action you want to take in this case, and
warning: avoid seeing this …Run Code Online (Sandbox Code Playgroud) 我的新分支工作流程是:
git checkout -b <new branch name>
// making changes, commit the changes
git push -u origin <new branch name>
Run Code Online (Sandbox Code Playgroud)
有没有办法将本地分支推送到新的远程分支,而无需再次写入分支名称(本地和远程分支将具有相同的名称)?每天我都会创建至少 1 个具有很长名称的功能分支,并且在一天结束时我必须返回 JIRA 板以获取项目 ID 和会议所需的其他内容。我只是好奇是否有一些 hack 可以获取本地分支名称并将其直接传递给git push -u origin <local branch name>
以下命令如何:
git config remote.origin.push refs/heads/master:refs/heads/master
Run Code Online (Sandbox Code Playgroud)
与以下命令有关:
git config push.default <option>
Run Code Online (Sandbox Code Playgroud)
(使用--local 或--global选项)
其中<option> 一个是:
nothing
matching
upstream (formerly tracking)
current
simple
Run Code Online (Sandbox Code Playgroud)
?
我想我理解第二个配置命令,但我不明白第一个命令条件/与第二个命令的关系.以下是一些提供此问题背后的背景的参考资料:
我的机器上有一个我前段时间克隆的旧仓库,想知道如果我运行它会推送到哪里:
git push
我怎么知道它会推到哪里?
$ git branch
master
* portal
$ git fetch
$ git merge origin/portal
Already up-to-date.
$ git pull
Already up-to-date.
$ git push
To git@github.com:ripper234/Commerce-Sciences.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:ripper234/Commerce-Sciences.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
Run Code Online (Sandbox Code Playgroud)
通常我会gitk -all尝试看看到底发生了什么,但这是在没有图形shell的Linux机器上.
我以为我的git配置有问题,
每当我创建一个新的分支时,我首先必须设置 - 上游
git push --set-upstream sensorAtHome pull-down-to-refresh
sensorAtHome我的项目名称在哪里,pull-down-to-refresh是分支名称.
实际上我没有必要在我的工作场所这样做,我简单创建分支做我的工作提交和推送,我从来没有设置 - 上游,但我在家里的项目,当我推送到GitHub.com我必须..
有什么我错过的可能与我的工作流程有关吗?
git ×7