本文翻译自:
git error: failed to push some refs to
For some reason, I can't push now, whereas I could do it yesterday.
由于某种原因,我现在不能推动,而昨天却可以。
Maybe I messed up with configs or something.
也许我搞砸了配置或其他东西。
This is what happens:
这是发生了什么:
When I use the git push origin master
当我使用git push origin master
What my working directory and remote repository looks like:
我的工作目录和远程存储库如下所示:
参考:
https://stackoom.com/question/1dBKO/git错误-无法将一些引用推送到
If the GitHub repo has seen new commits pushed to it, while you were working locally, I would advise using:
如果您在本地工作时,GitHub存储库中看到有新提交提交,建议您使用:
git pull --rebase
git push
The full syntax is: 完整语法为:
git pull --rebase origin master
git push origin master
With Git 2.6+ (Sept. 2015), after having done (once) 完成一次之后, 使用Git 2.6+ (2015年9月)
git config --global pull.rebase true
git config --global rebase.autoStash true
A simple git pull
would be enough. 一个简单的git pull
就足够了。
That way, you would replay (the --rebase
part) your local commits on top of the newly updated origin/master
(or origin/yourBranch
: git pull origin yourBranch
). 这样,您将在新近更新的origin/master
(或origin/yourBranch
: git pull origin yourBranch
)之上重播( --rebase
部分)本地提交。
See a more complete example in the chapter 6 Pull with rebase of the Git Pocket Book . 请参阅《 Git Pocket Book的第6章重装基础》中的更完整示例。
I would recommend a: 我建议:
git push -u origin master
That would establish a tracking relationship between your local master branch and its upstream branch. 这将在本地主分支与其上游分支之间建立跟踪关系。
After that, any future push for that branch can be done with a simple: 之后,可以使用以下简单的方法完成对该分支的将来任何推送:
git push
See " Why do I need to explicitly push a new branch? ". 请参阅“ 为什么需要显式推送新分支? ”。
Since the OP already reset and redone its commit on top of origin/master
: 由于OP已经重置并在origin/master
之上重做其提交 :
git reset --mixed origin/master
git add .
git commit -m "This is a new commit for what I originally planned to be amended"
git push origin master
There is no need to pull --rebase
. 无需pull --rebase
。
Note: git reset --mixed origin/master
can also be written git reset origin/master
, since the --mixed
option is the default one when using git reset
. 注意: git reset --mixed origin/master
也可以写成git reset origin/master
,因为--mixed
选项是使用git reset
时的默认选项。
I find the solution to this problem in github help. 我在github帮助中找到了解决此问题的方法。
You can see it from: Dealing with non-fast-forward errors 您可以从以下内容中看到它: 处理非快进错误
It says: 它说:
You can fix this by fetching and merging the changes made on the remote branch with the changes that you have made locally: 您可以通过获取和合并在远程分支上所做的更改与您在本地所做的更改来解决此问题:
$ git fetch origin
# Fetches updates made to an online repository
$ git merge origin branch
# Merges updates made online with your local work
Or, you can simply use git pull to perform both commands at once: 或者,您可以简单地使用git pull一次执行两个命令:
$ git pull origin branch
# Grabs online updates and merges them with your local work
If you just used git init
and have added your files with git add .
如果您只是使用git init
并使用git add .
文件git add .
or something similar and have added your remote branch it might be that you just haven't committed ( git commit -m 'commit message'
) anything locally to push to the remote... I just had this error and that was my issue. 或类似的东西并添加了远程分支,可能是您只是没有在本地git commit -m 'commit message'
任何内容( git commit -m 'commit message'
)以将其推送到远程...我只是遇到了这个错误,这就是我的问题。
If you are using gerrit, this could be caused by an inappropriate Change-id in the commit. 如果使用的是gerrit,则可能是由于提交中的Change-id不正确所致。 Try deleting the Change-Id and see what happens. 尝试删除Change-Id,看看会发生什么。
Remember to commit your changes before pushing to Github repo. 在推送到Github存储库之前,请记住先进行更改。 This might fix your problem. 这可能会解决您的问题。
For some reason, I can't push now, whereas I could do it yesterday. 由于某种原因,我现在不能推动,而昨天却可以。 Maybe I
pip install -e .
NOTION_TOKEN_V2 - 可以在 Notion 网站的中找到。 NOTION_ROOT_PAGE - 概念页面的 URL。 Repo docs 将是此页面下的一个新页面。 NOTION_IGNORE_REGEX - 忽略路径的NOTION_IGNORE_REGEX表达式。
可以设置这些环境变量。
export NOTION_TOKEN_V2= < YOUR>
export NOTION_ROOT
git push到GitHub的时候遇到! [rejected] master -> master (non-fast-forward)的问题
[rejected] master -> master (non-fast-forward)…
上传文件到git上传不上去的时候,有时候是因为上传的文件夹与git仓库中的文件不同步,缺少文件,此时进行下列步骤,实现本地文件夹和远程仓库的同步就能上传成功。
1、git pull origin master --allow-unrelated-hist
尚硅谷2021最新Git教程笔记1、Git概述
1、Git概述
Git 是一个免费的、开源的分布式版本控制系统,可以快速高效地处理从小型到大型的各种项目。Git 易于学习,占地面积小,性能极快。 它具有廉价的本地库,方便的暂存区域和多个工作流分支等特性。其性能优于 Subversion、CVS、Perforce 和 ClearCase 等版本控制工具。
Username for ‘https://gitee.com’: Lizhiming0321
Password for ‘https://Lizhiming0321@gitee.com’:
To https://gitee.com/Lizhiming0321/LZMtest.git
! [rejected] master ...
执行git push命令后,输出以下错误:
Counting objects: 54, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (7/7), 631 bytes | 0 bytes/s, done.
Total 7 (de
He-NingQiu@LAPTOP-HTU50PHP MINGW64 /f/MyItem_git/OurTeam_git/Match (hnq)
$ git merge hnq
Already up to date.
He-NingQiu@LAPTOP-HTU50PHP MINGW64...
1. 在 Gitee 上创建一个新的仓库或者在已有的仓库中新建一个分支(branch)。
2. 在本地计算机上将您的项目文件夹初始化为 Git 仓库。您可以通过在项目文件夹中打开终端并输入以下命令来实现:
git init
3. 将项目中的文件添加到 Git 仓库。您可以通过运行以下命令来添加所有更改的文件:
git add .
4. 提交您的更改并添加提交消息:
git commit -m "提交消息"
在提交消息中,您应该简要描述您所做的更改。
5. 添加一个远程 Git 仓库。在这里,您需要提供 Gitee 仓库的 URL。您可以通过运行以下命令来添加远程仓库:
git remote add origin <Gitee 仓库 URL>
6. 将本地分支推送到 Gitee 仓库。在这里,您需要将本地分支与远程分支进行关联。您可以通过运行以下命令来推送分支:
git push -u origin <分支名>
第一次推送时需要加上 `-u` 参数,以将本地分支与远程分支进行关联。
完成以上步骤后,您的项目就已经成功推送到 Gitee 上了。您可以在 Gitee 仓库页面上查看您的项目和提交记录。