How to update local github copies of VisionFive2 repository

I’ve been practicing making Linux builds with both the simple README.md procedure in GitHub - starfive-tech/VisionFive2 and the more manual procedure in Building StarFive Debian image | RVspace. Each of these two different procedures is in a separate file hierarchy on my PC so the two don’t share anything with my local copies of the repositories.

As part of that exercise, I pulled a copies of several of the StarFive Github repositories into my local PC. The following are from the VisionFive2 repository:

  • VisionFive2
  • linux
  • buildroot
  • opensbi
  • soft_3rdpart
  • u-boot

The second Linux image build procedure uses several git clone commands to clone some of the same repositories such as linux and soft_3rdpart.

I also did a git checkout JH7110_VisionFive2_devel as part of executing the second image build procedure.

Since there are changes to the remote repositories that I would like to have to update my copies, what are the git commands that I would use and in what directory would I use them?

Doing some reading, it would appear that going to the top directory for each source code tree and then using git pull would work however from some posts I’ve seen, it appears that having used the git checkout command, that complicates matters.

How are other people ensuring they have the most current copy of the source code?

Here is the simple explanation of git pull, Git Guides - git pull · GitHub. It would appear that git pull --all would be the ticket however this Stackoverflow post indicates otherwise, Can “git pull --all” update all my local branches? - Stack Overflow.

When I do a git pull --dry-run I get the following notes.

rick@rchamber2:~/Documents/starfive/github/VisionFive2$ git pull --dry-run
remote: Enumerating objects: 16, done.
remote: Counting objects: 100% (16/16), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 16 (delta 12), reused 14 (delta 10), pack-reused 0
Unpacking objects: 100% (16/16), 2.15 KiB | 734.00 KiB/s, done.
From https://github.com/starfive-tech/VisionFive2
   7f3d98e..effff70  JH7110_VisionFive2_devel       -> origin/JH7110_VisionFive2_devel
   bc756b0..d099d25  JH7110_VisionFive2_6.1.y_devel -> origin/JH7110_VisionFive2_6.1.y_devel
 * [new tag]         JH7110_VF2_515_v3.9.3          -> JH7110_VF2_515_v3.9.3
 * [new tag]         JH7110_VF2_6.1_v3.9.3          -> JH7110_VF2_6.1_v3.9.3
 * [new tag]         JH7110_VF2_515_v3.9.3          -> JH7110_VF2_515_v3.9.3
 * [new tag]         JH7110_VF2_6.1_v3.9.3          -> JH7110_VF2_6.1_v3.9.3
Fetching submodule buildroot
From https://github.com/starfive-tech/buildroot
   22fc8eaf..0efa289b  JH7110_VisionFive2_devel -> origin/JH7110_VisionFive2_devel
 * [new tag]           JH7110_VF2_515_v3.9.3 -> JH7110_VF2_515_v3.9.3
 * [new tag]           JH7110_VF2_6.1_v3.9.3 -> JH7110_VF2_6.1_v3.9.3
 * [new tag]           JH7110_VF2_515_v3.9.3 -> JH7110_VF2_515_v3.9.3
 * [new tag]           JH7110_VF2_6.1_v3.9.3 -> JH7110_VF2_6.1_v3.9.3
Fetching submodule linux
From https://github.com/starfive-tech/linux
   b133739ab239..e5249867764f  JH7110_VisionFive2_devel -> origin/JH7110_VisionFive2_devel
   22e0315434b1..39daafe74ea5  JH7110_VisionFive2_6.1.y_devel -> origin/JH7110_VisionFive2_6.1.y_devel
 + f7c19b2d41e0...e1386a7be3ea esmil_starlight       -> origin/esmil_starlight  (forced update)
 + f7c19b2d41e0...e1386a7be3ea visionfive            -> origin/visionfive  (forced update)
 * [new tag]                   JH7110_VF2_515_v3.9.3 -> JH7110_VF2_515_v3.9.3
 * [new tag]                   JH7110_VF2_6.1_v3.9.3 -> JH7110_VF2_6.1_v3.9.3
 * [new tag]                   JH7110_VF2_515_v3.9.3 -> JH7110_VF2_515_v3.9.3
 * [new tag]                   JH7110_VF2_6.1_v3.9.3 -> JH7110_VF2_6.1_v3.9.3
Fetching submodule soft_3rdpart
From https://github.com/starfive-tech/soft_3rdpart
   62620fe..12d2bb4  JH7110_VisionFive2_devel -> origin/JH7110_VisionFive2_devel
 * [new tag]         JH7110_VF2_515_v3.9.3 -> JH7110_VF2_515_v3.9.3
 * [new tag]         JH7110_VF2_6.1_v3.9.3 -> JH7110_VF2_6.1_v3.9.3
 * [new tag]         JH7110_VF2_515_v3.9.3 -> JH7110_VF2_515_v3.9.3
 * [new tag]         JH7110_VF2_6.1_v3.9.3 -> JH7110_VF2_6.1_v3.9.3
rick@rchamber2:~/Documents/starfive/github/VisionFive2$

So it looks like a git pull would only update the branch I have checked out. Would that be sufficient?

VisionFive2 and all of its submodules need to be updating.
1.method 1:git pull VisionFive2 and enter every submodule to git pull
2.method 2:git pull VisionFive2 and use git submodule foreach ‘git pull’ to updating submodule and you can use git submodule foreach ‘git branch’ to check their branch.

@kira Please correct me if I’ve misinterpreted what you posted however you are suggesting two different methods for properly and completely updating the source tree.

The first method is to do start in the VisionFive2 directory, perform a git pull there to update what is under the Git versioning there and to then go to each subdirectory that is a submodule and perform a git pull there. This would require me to properly identify all of the submodules and cd to the proper directory to do the git pull.

The second method is to start in the VisionFive2 directory, perform a git pull there to update what is under the Git versioning there and to the use a second command, git submodule foreach ‘git pull’, to ask Git to visit each submodule and perform a git pull.

The second method would seem superior since if anyone should know what is a submodule, it should be Git.

I looked at the documentation for the git submodule command at Git - git-submodule Documentation as well as the documentation on submodules at Git - gitsubmodules Documentation to better understand what you are writing.

What I don’t fully understand is the difference between the list of submodules provided by Git with the git submodule command to list the submodules and the complete list of all directories that have a .git file. I would assume that each directory that has a .git file is another Git repository and I would need to do a git pull in that directory to update it.

For example in the following I used the git submodule command to list the submodules for VisionFive2 repository and then used find . -iname “.git” to find all directories that have a .git file in them. The list from the find command has more directories in it, 19 from the find and 5 from the git submodule.

However it may be that the various .git files in the ./buildroot/dl/ tree are temporary and recreated with the next make as are the .git files in the ./work tree. There is no subdirectory named dl in the buildroot repository on GitHub nor is there a work directory in the VisionFive2 repository on GitHub. And I just found the .gitmodules file in the VisionFive2 repository which lists the same 5 submodules reported by git submodules.

rick@rchamber2:~/Documents/starfive/github/VisionFive2$ git submodule foreach 'git pull --dry-run'
Entering 'buildroot'
Entering 'linux'
Entering 'opensbi'
remote: Enumerating objects: 2, done.
remote: Counting objects: 100% (2/2), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 2 (delta 1), reused 1 (delta 0), pack-reused 0
Unpacking objects: 100% (2/2), 245 bytes | 122.00 KiB/s, done.
From https://github.com/starfive-tech/opensbi
 * [new tag]         JH7110_VF2_515_v3.9.3 -> JH7110_VF2_515_v3.9.3
 * [new tag]         JH7110_VF2_6.1_v3.9.3 -> JH7110_VF2_6.1_v3.9.3
 * [new tag]         JH7110_VF2_515_v3.9.3 -> JH7110_VF2_515_v3.9.3
 * [new tag]         JH7110_VF2_6.1_v3.9.3 -> JH7110_VF2_6.1_v3.9.3
Entering 'soft_3rdpart'
Entering 'u-boot'
remote: Enumerating objects: 2, done.
remote: Counting objects: 100% (2/2), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 2 (delta 1), reused 1 (delta 0), pack-reused 0
Unpacking objects: 100% (2/2), 245 bytes | 245.00 KiB/s, done.
From https://github.com/starfive-tech/u-boot
 * [new tag]               JH7110_VF2_515_v3.9.3 -> JH7110_VF2_515_v3.9.3
 * [new tag]               JH7110_VF2_6.1_v3.9.3 -> JH7110_VF2_6.1_v3.9.3
 * [new tag]               JH7110_VF2_515_v3.9.3 -> JH7110_VF2_515_v3.9.3
 * [new tag]               JH7110_VF2_6.1_v3.9.3 -> JH7110_VF2_6.1_v3.9.3
rick@rchamber2:~/Documents/starfive/github/VisionFive2$ find . -iname ".git"
./u-boot/.git
./linux/.git
./opensbi/.git
./soft_3rdpart/.git
./buildroot/dl/gst1-interpipe/git/common/.git
./buildroot/dl/gst1-interpipe/git/.git
./buildroot/dl/linux/git/.git
./buildroot/dl/libcamera-apps/git/.git
./buildroot/dl/gst1-shark/git/common/.git
./buildroot/dl/gst1-shark/git/.git
./buildroot/dl/libyuv/git/.git
./buildroot/dl/x264/git/.git
./buildroot/dl/libcamera/git/.git
./buildroot/.git
./.git
./work/buildroot_rootfs/build/gst1-interpipe-1.1.7/common/.git
./work/buildroot_rootfs/build/gst1-shark-v0.7.3/common/.git
./work/buildroot_initramfs/build/gst1-interpipe-1.1.7/common/.git
./work/buildroot_initramfs/build/gst1-shark-v0.7.3/common/.git
rick@rchamber2:~/Documents/starfive/github/VisionFive2$

yes it is two methods.
The second method is just a simple way to git pull,it doesn’t need you to enter in every submodule.

it does not matter.

1 Like

I decide to just go with the second method and I have run into a problem with one of the repositories, u-boot. If I understand the error correctly, I do not have a branch specified for the u-boot repository like I do for the others.

Entering 'u-boot'
From https://github.com/starfive-tech/u-boot
 * [new tag]               JH7110_VF2_515_v3.9.3 -> JH7110_VF2_515_v3.9.3
 * [new tag]               JH7110_VF2_6.1_v3.9.3 -> JH7110_VF2_6.1_v3.9.3
You are not currently on a branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

fatal: run_command returned non-zero status for u-boot
.

What I did to resolve this was to cd to the u-boot directory and the use the command git checkout JH7110_VisionFive2_devel which is what I remember doing with the other submodules.

Then I double checked the README.md file in VisionFive2 repository, which I should have done before depending on my aging memory, and discovered that one of the setup commands is cd u-boot && git checkout --track origin/JH7110_VisionFive2_devel && cd .. so it should have already been set but wasn’t. So obviously I made a mistake there.

So what I did to fix this was to cd u-boot, git checkout master, git branch -d JH7110_VisionFive2_devel, then git checkout --track origin/JH7110_VisionFive2_devel. See this Stackoverflow post How do I undo a checkout in git? - Stack Overflow

Here is the complete session including my mistakes.

rick@rchamber2:~/Documents/starfive/github/VisionFive2$ cd u-boot
rick@rchamber2:~/Documents/starfive/github/VisionFive2/u-boot$ git checkout JH7110_VisionFive2_devel
Switched to branch 'JH7110_VisionFive2_devel'
Your branch is up to date with 'origin/JH7110_VisionFive2_devel'.
rick@rchamber2:~/Documents/starfive/github/VisionFive2/u-boot$ cd ..
rick@rchamber2:~/Documents/starfive/github/VisionFive2$ git submodule foreach 'git pull'
Entering 'buildroot'
Already up to date.
Entering 'linux'
Already up to date.
Entering 'opensbi'
Already up to date.
Entering 'soft_3rdpart'
Already up to date.
Entering 'u-boot'
Already up to date.
rick@rchamber2:~/Documents/starfive/github/VisionFive2$ cd u-boot && git checkout --track origin/JH7110_VisionFive2_devel && cd ..
fatal: A branch named 'JH7110_VisionFive2_devel' already exists.
rick@rchamber2:~/Documents/starfive/github/VisionFive2/u-boot$ git branch -d JH7110_VisionFive2_devel
error: Cannot delete branch 'JH7110_VisionFive2_devel' checked out at '/home/rick/Documents/starfive/github/VisionFive2/.git/modules/u-boot'
rick@rchamber2:~/Documents/starfive/github/VisionFive2/u-boot$ get checkout master
Command 'get' not found, but there are 18 similar ones.
rick@rchamber2:~/Documents/starfive/github/VisionFive2/u-boot$ git checkout master
Branch 'master' set up to track remote branch 'master' from 'origin'.
Switched to a new branch 'master'
rick@rchamber2:~/Documents/starfive/github/VisionFive2/u-boot$ git checkout --track origin/JH7110_VisionFive2_devel
fatal: A branch named 'JH7110_VisionFive2_devel' already exists.
rick@rchamber2:~/Documents/starfive/github/VisionFive2/u-boot$ git branch -d JH7110_VisionFive2_devel
warning: deleting branch 'JH7110_VisionFive2_devel' that has been merged to
         'refs/remotes/origin/JH7110_VisionFive2_devel', but not yet merged to HEAD.
Deleted branch JH7110_VisionFive2_devel (was 84c81d3d02).
rick@rchamber2:~/Documents/starfive/github/VisionFive2/u-boot$ git checkout --track origin/JH7110_VisionFive2_devel
Branch 'JH7110_VisionFive2_devel' set up to track remote branch 'JH7110_VisionFive2_devel' from 'origin'.
Switched to a new branch 'JH7110_VisionFive2_devel'
rick@rchamber2:~/Documents/starfive/github/VisionFive2/u-boot$ cd ..
rick@rchamber2:~/Documents/starfive/github/VisionFive2$ ls
Makefile   bsp       build_soft_3rdpart.sh  conf    genimage.sh  opensbi        pre-build.sh  u-boot
README.md  build.sh  buildroot              fsz.sh  linux        post-build.sh  soft_3rdpart  work
rick@rchamber2:~/Documents/starfive/github/VisionFive2$ git submodule foreach 'git pull'
Entering 'buildroot'
Already up to date.
Entering 'linux'
Already up to date.
Entering 'opensbi'
Already up to date.
Entering 'soft_3rdpart'
Already up to date.
Entering 'u-boot'
Already up to date.
rick@rchamber2:~/Documents/starfive/github/VisionFive2$

@kira I just wanted to thank you for your assistance over these last few days. I would have been a lot less purposeful in my bumbling about and made much less progress if you hadn’t provided guidance.

You are welcome, I’m glad my comments helped.