1024programmer News git switch branch initialization

git switch branch initialization

Common errors

The content of the error report is basically error: failed to push some refsto’remote warehouse address’.

Causes

We want to associate a local project with a remote warehouse and push it

Operation

  • Local project—>remote warehouse—>local associated remote—>push the latest code
  • Errors are often found in the last step

Root Cause

When we create a warehouse, we always check the “Use Reamdme file to initialize this warehouse” This operation first met a README file and configured to add an ignore file. When clicking to create a warehouse,

It will do an initial commit for us. So our warehouse has README.m and .gitignore files, and then we associate the local project to this warehouse and push the project to the warehouse. When we associate the local and remote, both ends have content, but These two contents are not related. When we push to or pull content from remote, there will be untracked content, so you will always ask you to pull first and then push in the detailed errors reported by git, but Pull always fails.

Solution
Method 1
For error: failed to push some refsto’remote warehouse address’
1 Use the following command
git pull –rebase origin master

2 Then upload again:

git push -u origin master

Push successfully

Method 2

  • To avoid this kind of problem, just The repo to keep created is an empty repo with nothing.
  • When creating a warehouse, do not check “Use the Readme file to initialize this warehouse”

  • Then clone it for easy use, and you can push it directly next time you want to push it.

Original link: https://blog.csdn.net/qq_45893999/article/details/106273214

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/git-switch-branch-initialization/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索