Home > Back-end >  why could not pull github branch code to local machine
why could not pull github branch code to local machine

Time:10-30

I want to pull the repo https://github.com/jiangxiaoqiang/crx-selection-translate code to my local machine from github now. I swith to the remote 6.x-master branch in google chrome browser in github and find this branch contains source code, but when I want to pull the source code into my local machine using this command:

[dolphin@MiWiFi-R4CM-srv]~/Documents/GitHub/crx-selection-translate% git pull -v
POST git-upload-pack (122 bytes)
From https://github.com/jiangxiaoqiang/crx-selection-translate
 = [up to date]      6.x-master         -> origin/6.x-master
 = [up to date]      4.x-master         -> origin/4.x-master
 = [up to date]      5.x-master         -> origin/5.x-master
 = [up to date]      7.x-master         -> origin/7.x-master
 = [up to date]      porting-to-firefox -> origin/porting-to-firefox
Already up to date.

tell me already up to date, but my local machine did not contain any source code:

[dolphin@MiWiFi-R4CM-srv]~/Documents/GitHub/crx-selection-translate% git branch
* 6.x-master
  7.x-master
[dolphin@MiWiFi-R4CM-srv]~/Documents/GitHub/crx-selection-translate% ls
README.md

Am I missing something? what should I do to fetch the github remote 6.x-master source code into my local machine? I also tried this command:

[dolphin@MiWiFi-R4CM-srv]~/Documents/GitHub/crx-selection-translate% git pull origin 6.x-master
From https://github.com/jiangxiaoqiang/crx-selection-translate
 * branch            6.x-master -> FETCH_HEAD
Already up to date.

The branch 6.x-master was checkout from 7.x-master in my local machine.

In my work, I always pull local branch A from remote branch A using this command: git pull origin A, it seems did not work in this repo. I could not figure out where am I going wrong, It is strange. When I am run git status,shows info like this:

[dolphin@MiWiFi-R4CM-srv]~/Documents/GitHub/crx-selection-translate% git status
On branch 6.x-master
Your branch is ahead of 'origin/6.x-master' by 16 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

then I run the git push command:

[dolphin@MiWiFi-R4CM-srv]~/Documents/GitHub/crx-selection-translate% git push 
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/jiangxiaoqiang/crx-selection-translate.git
   5a9ca26..12b9ef2  6.x-master -> 6.x-master
[dolphin@MiWiFi-R4CM-srv]~/Documents/GitHub/crx-selection-translate% git pull
Already up to date.
[dolphin@MiWiFi-R4CM-srv]~/Documents/GitHub/crx-selection-translate% ls
README.md

still not have the source code of 6.x-master. I also tried this command:

[dolphin@MiWiFi-R4CM-srv]~/Documents/GitHub% git clone -b 6.x-master https://github.com/jiangxiaoqiang/crx-selection-translate.git
Cloning into 'crx-selection-translate'...
remote: Enumerating objects: 4587, done.
remote: Counting objects: 100% (85/85), done.
remote: Compressing objects: 100% (77/77), done.
remote: Total 4587 (delta 27), reused 15 (delta 5), pack-reused 4502
Receiving objects: 100% (4587/4587), 1.55 MiB | 734.00 KiB/s, done.
Resolving deltas: 100% (2816/2816), done.
[dolphin@MiWiFi-R4CM-srv]~/Documents/GitHub% cd crx-selection-translate 
[dolphin@MiWiFi-R4CM-srv]~/Documents/GitHub/crx-selection-translate% ls
README.md

still not contains the source code.

CodePudding user response:

You wrote

the branch 6.x-master was checkout from 7.x-master in my local machine

And you wrote that the output of git status is

On branch 6.x-master
Your branch is ahead of 'origin/6.x-master' by 16 commits.

This tells me that your situation is like this:

o <-- origin/7.x-master <-- 6.x-master
|
o
|
[... 14 other commits ...]
|
o
|
o <-- origin/6.x-master
|
o
|

But you want:

o <-- origin/7.x-master
|
o
|
[... 14 other commits ...]
|
o
|
o <-- origin/6.x-master <-- 6.x-master
|
o
|

i.e., your local 6.x.-master branch is too far ahead.

So you have to reset it to origin/6.x-master:

git checkout 6.x-master
git reset --hard origin/6.x-master

You also wrote

[git pull] tell me already up to date, but my local machine did not contain any source code

There was no source code because that was the state of the origin/7.x-master branch at the time, which you had checked out under the local name 6.x-master.

  •  Tags:  
  • git
  • Related