Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Git checkout with branch , git status reports no branch #3661

jclx ·
PMEase QuickBuild, 6.1.26
Using GIT repository definition to checkout a branch
Fetch URL: ssh://git@....
Branch Name: develop
Destination Path: app

Then build run and shows this in log:
Checking out revision 'cb8e8b2c8b12356f74ebad5ef8de1723ca64aecd' of repository 'GitApp'...

But if you go this directory after a build git doesn't show correct branch or details.

C:\...app>git branch --list
* (HEAD detached at cb8e8b2)
master

C:\...\app>git status
HEAD detached at cb8e8b2
Untracked files:
(use "git add <file>..." to include in what will be committed)
.qbcache/
nothing added to commit but untracked files present (use "git add" to track)

Manually switching to branch via checkout, status seems correct:
C:\...\app>git checkout develop
Branch develop set up to track remote branch develop from origin.
Switched to a new branch 'develop'

C:\...\appl>git status
On branch develop
Your branch is up-to-date with 'origin/develop'.
Untracked files:
(use "git add <file>..." to include in what will be committed)

.qbcache/

nothing added to commit but untracked files present (use "git add" to track)

We make git calls manually via ant scripts and to use this we have to first do a git checkout develop
before our ant scripts can do git commit/push.

BTW: I added .qbcache to .gitingore so this won't show up anymore.

Any insight, suggestions?
  • replies 3
  • views 3856
  • stars 0
robinshen ADMIN ·
To ensure exactly the same set of source is used during build (calculate changes since prev build, checkout build, label build, etc.) QB determines the tip commit of a branch at start of build, and uses that commit across the whole build, that is why you see workspace in detached state. However you may add a script step after checkout step to move the workspace to branch head if necessary:
groovy:
repositories.get("your repo name").switchToHead();
jclx ·
Oh that explains it.
What does switchToHead() execute?
I was doing 'git checkout <branch>'
robinshen ADMIN ·
It does the following:
git checkout branch
git reset --hard <the checkout revision>

This way QuickBuild makes sure the branch head points to the checkout revision determined at start of the build. Also when you make some commits and want to push to remote, it will fail if some other one is already make some commits after the checkout revision, which will protect other one's commit from being overwritten.