Multiple ways to solve the error There is no tracking information for the current branch

1. Reproduce the error


Release a certain version of the project today, and prepare to create a v0point1branch. If you modify this version later, you can directly modify it on this branch.

First, use git branch v0point1the command to create a local branch v0point1, as shown in the following figure:

insert image description here

Second, use git checkout v0point1the command to switch to v0point1the branch, as shown in the following figure:

insert image description here

Of course, we can also use git checkout -b v0point1commands to create and switch to v0point1branches.

But on v0point1the branch, using git pullthe command to pull the remote code, the following prompt is reported:

insert image description here

Right nowThere is no tracking information for the current branch.

2. Analysis errors


There is no tracking information for the current branch., this sentence is translated into Chinese 当前分支没有跟踪信息.

当前分支Refers to the remote branch.

In other words, I have created v0point1a branch locally and have no v0point1branch associated with the remote warehouse. There may be the following two situations:

  1. A remote repository itself has no v0point1branches.

  2. The branch exists v0point1remotely, but I am not associated with the remote repository.

Therefore, for these two situations, there are the following two solutions.

3. Fix bugs


Since the local branch is not associated with the remote branch, the error can be solved in the following two ways.

3.1 Remote branches


As shown in the figure below, a v0point1branch exists remotely, as shown in the figure below:

insert image description here

Use git statusthe command to check whether the local branch is v0point1, as shown in the following figure:

insert image description here

As can be seen from the figure, the local branch is already available v0point1. We use the following command to merge the remote branch:

  
  git branch --set-upstream-to=origin/远程分支名 本地分支名

insert image description here

From thisBranch 'v0point1' set up to track remote branch 'v0point1' from 'origin'. sentence, we can see that the local v0point1branch has been associated with the remote branch.

3.2 Remote branchless


As shown in the figure below, I deleted the remote branch, only the local branch, pushed to the remote, and associated with the remote branch.

insert image description here

Still use git statusthe command to check whether the local branch is v0point1, as shown in the following figure:

insert image description here

As can be seen from the figure, the local branch is already available v0point1. We use the following command to submit the local branch to the remote warehouse:


git push origin 本地分支名

insert image description here

To create a merge request for v0point1As you can see from this

Use the following command,


git branch --set-upstream-to=origin/远程分支名

insert image description here

From thisBranch 'v0point1' set up to track remote branch 'v0point1' from 'origin'. sentence, we can see that the local v0point1branch has been associated with the remote branch.

In order to verify whether the local branch is associated with the remote branch, check gitlabwhether there is v0point1a branch on it, as shown in the following figure:

insert image description here

gitlabv0point1Branch already exists on .

4. Summary


If the above methods cannot solve your problem, please leave a message in the comment area.

Guess you like

Origin blog.csdn.net/lvoelife/article/details/130506243
Recommended