Article directory
1. Reproduce the error
Release a certain version of the project today, and prepare to create a v0point1
branch. If you modify this version later, you can directly modify it on this branch.
First, use git branch v0point1
the command to create a local branch v0point1
, as shown in the following figure:
Second, use git checkout v0point1
the command to switch to v0point1
the branch, as shown in the following figure:
Of course, we can also use git checkout -b v0point1
commands to create and switch to v0point1
branches.
But on v0point1
the branch, using git pull
the command to pull the remote code, the following prompt is reported:
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 v0point1
a branch locally and have no v0point1
branch associated with the remote warehouse. There may be the following two situations:
-
A remote repository itself has no
v0point1
branches. -
The branch exists
v0point1
remotely, 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 v0point1
branch exists remotely, as shown in the figure below:
Use git status
the command to check whether the local branch is v0point1
, as shown in the following figure:
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/远程分支名 本地分支名
From thisBranch 'v0point1' set up to track remote branch 'v0point1' from 'origin'.
sentence, we can see that the local v0point1
branch 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.
Still use git status
the command to check whether the local branch is v0point1
, as shown in the following figure:
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 本地分支名
To create a merge request for v0point1
As you can see from this
Use the following command,
git branch --set-upstream-to=origin/远程分支名
From thisBranch 'v0point1' set up to track remote branch 'v0point1' from 'origin'.
sentence, we can see that the local v0point1
branch has been associated with the remote branch.
In order to verify whether the local branch is associated with the remote branch, check gitlab
whether there is v0point1
a branch on it, as shown in the following figure:
gitlab
v0point1
Branch already exists on .
4. Summary
If the above methods cannot solve your problem, please leave a message in the comment area.