Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to let git pull from branch not from tag?

Tags:

git

git-pull

Our repo happens to have a tag that has the same name as the branch name. So when I try to pull from that branch, git confused and pulled from tag, like this. I have to delete that tag first to make my git pull work.

So how do I tell git pull from branch not from tag ?

cc-backend ➤ git pull origin 0.9.0-rc6-patch1                                       
From 10.0.0.28:webcc/cc-backend
 * tag                 0.9.0-rc6-patch1 -> FETCH_HEAD
Already up to date.

/* I have to delete that tag and git pull again to get the result I want */

cc-backend ➤ git pull origin 0.9.0-rc6-patch1                                       
From 10.0.0.28:webcc/cc-backend
 * branch              0.9.0-rc6-patch1 -> FETCH_HEAD
Updating 9d7e9dc3..2bf3f96a
Fast-forward
 app/Services/GroupSeat/Seat.php | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
like image 761
Qiulang 邱朗 Avatar asked Jul 23 '19 04:07

Qiulang 邱朗


2 Answers

It seems the remote repository has a tag and a branch with the same name 0.9.0-rc6-patch1. Use the full name to fetch/pull,

# fetch/pull the tag
git fetch/pull origin refs/tags/0.9.0-rc6-patch1

# fetch/pull the branch
git fetch/pull origin refs/heads/0.9.0-rc6-patch1
like image 200
ElpieKay Avatar answered Nov 05 '22 01:11

ElpieKay


You should use the full name like

git checkout refs/heads/<branchname>

or for tag

git checkout refs/tags/<refname>

For pull git pull origin refs/heads/<branchname>

To access the relevant documentation type in git help revisions

Refer the SPECIFYING REVISIONS section

like image 28
Mohit Mutha Avatar answered Nov 05 '22 01:11

Mohit Mutha