使最新的提交主(git) [英] making latest commit master (git)
问题描述
以下是我通常所做的:
$ git add。 -Av
$ git commit -m我希望这是主人
但是当我尝试推送到远程,一切都是最新的,最新的提交不是主人。
$ git branch
*(HEAD从f0efe1a分离)
added_mongodb_auth
master
serviceworkers_branch
我怎样才能使最新的提交大师?
查看 git branch
,看起来你目前不在任何分支(称为分离HEAD状态)。
成为在安全方面,首先创建一个包含迄今为止创建的提交的新分支(save-my-work
):
$ git branch save-my-work
现在,将这些提交包含在 master
分支中:
$ git checkout master
$ git merge save-my-work
现在你应该照常推送。如果您确定 master
处于您想要的状态,您可以删除 save-my-work
再次:
$ git branch -d save-my-work
$提示:使用像
gitk
这样的图形资源库查看器更好地了解存储库的状态。Here's what I usually do:
$ git add . -Av $ git commit -m "I want this to be master"
but when I try to push to remote, "everything is up-to-date" and the latest commit isn't master.
$ git branch * (HEAD detached from f0efe1a) added_mongodb_auth master serviceworkers_branch
How can I make the latest commit the Master?
解决方案Looking at the output of
git branch
, it appears you're not currently on any branch (called a "detached HEAD" state).To be on the safe side, first create a new branch (
"save-my-work"
) containing the commits you've created so far:$ git branch save-my-work
Now, to include these commits in the
master
branch:$ git checkout master $ git merge save-my-work
Now you should by able to push as usual. If you're sure that
master
is in the state that you want it, you can deletesave-my-work
again:$ git branch -d save-my-work
Tip: Use a graphical repository viewer like
gitk
to have a better overview of the state of the repository.这篇关于使最新的提交主(git)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!