Git clone - does not fast forward to the lastest of a branch

Hi!

I am using the build steps described here: How to Cache the Source Code directory

I’ve only have scheduled build setup (no web hooks or trigger).

When the workflow runs, git-clone is always stuck at the same commit SHA when the workflow was first run.

How to make git-clone fast forward to the latest commit?

Thanks
Bill

Build log:

Bitrise Build config:
- BuildURL: --------
- BuildAPIToken: --------
git "reset" "--hard" "HEAD"
HEAD is now at eda8670 Merge pull request #1 from schedorg/unit-test-fixes
git "clean" "-x" "-d" "-f"
git "submodule" "foreach" "git" "reset" "--hard" "HEAD"
Entering 'SchedKit/3rd-Parties/KeychainAccess'
HEAD is now at ec968d9 Merge pull request #352 from kishikawakatsumi/travis_retry
git "submodule" "foreach" "git" "clean" "-x" "-d" "-f"
Entering 'SchedKit/3rd-Parties/KeychainAccess'
git "init"
Reinitialized existing Git repository in /Users/vagrant/git/.git/
git "fetch"
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
From github.com:schedorg/mobile
   a9f9433..f7ade16  master     -> origin/master
git "checkout" "master"
Already on 'master'
Your branch is behind 'origin/master' by 20 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)
git "submodule" "update" "--init" "--recursive"
1 Like

Thanks for reporting @billsched!

Indeed the current version of the Git Clone step will not do a pull if all you define is to “clone the master branch” (without any commit hash, only the branch is provided) and you have a cache (so when the git clone step runs the repo is already there and the master branch is already checked out).

It of course works if you specify a commit hash as the git clone step ensures that your repo is in the state what you specified in its inputs.

I’ll bring this up for a discussion with the team, to do a pull in this case instead of just a fetch (if no commit hash is specified only the branch, and the cache already includes the source code with that branch checked out).

In the meantime:

  1. Either specify a commit hash when you trigger a build (if the build is triggered for a git event the hash is always specified, so the right hash is always checked out).
  2. Or don’t store the repository in the Cache (if the repo is not stored in cache the “checkout” will check out the latest version of the branch).

If you have any questions just let us know! :slight_smile:

Thanks for getting back!!

I thought this PR some time ago already fix the issue!

In the mean time, I’ll probably disable cache.

You’re right, it seems we forgot about this when we did the rewrite of the step recently (v4).

Will fix this ASAP (PR is already in review :wink: ) !

Hi @billsched,

Fix was released in the latest Git Clone step version (4.0.5): Git Clone Repository v4.0.5

Let us know if you’d have any issues with it! :wink:

Ohh and of course thank you for reporting the issue, and sorry for the inconvenience.