Commit to git repository broken with the error "Ref HEAD can not be resolved"


Description

Getting the below error when attempting to commit a change to a git repository using the studio. You can test this via refresh repository link under related link in sys_repo_config record for the application having issue and you should see the same error.

"An error occurred while executing that operation. Try again, check logs, and contact support if the error persists"

I checked the logs and found the following:
Error occurred while exporting application : com.glide.sourcecontrol.SourceControlException: org.eclipse.jgit.api.errors.RefNotFoundException: Ref HEAD can not be resolved: com.glide.sourcecontrol.AGitRepository.createBranch(AGitRepository.java:543)
com.glide.sourcecontrol.AGitRepository.createBranch(AGitRepository.java:522)
com.glide.sourcecontrol.AGitRepository.checkout(AGitRepository.java:575)
com.glide.sourcecontrol.AGitRepository.checkout(AGitRepository.java:551)
com.glide.sourcecontrol.worker.git.GitWorkerHelper.initRepo(GitWorkerHelper.java:93)
com.glide.sourcecontrol.worker.git.GitExportApplicationWorker.exportApp(GitExportApplicationWorker.java:150)
com.glide.sourcecontrol.worker.ExportApplicationWorker.execute(ExportApplicationWorker.java:126)
com.glide.sourcecontrol.SourceControlWorker.startWork(SourceControlWorker.java:41)
com.glide.worker.AbstractProgressWorker.startAndWait(AbstractProgressWorker.java:126)
com.glide.worker.HierarchicalProgressWorker.startAndWait(HierarchicalProgressWorker.java:26)
com.glide.worker.BackgroundProgressJob.execute(BackgroundProgressJob.java:59)
com.glide.schedule.JobExecutor.lambda$executeJob$0(JobExecutor.java:115)
com.glide.schedule.JobExecutor.executeJob(JobExecutor.java:118)
com.glide.schedule.JobExecutor.execute(JobExecutor.java:102)
com.glide.schedule_v2.SchedulerWorkerThread.executeJob(SchedulerWorkerThread.java:300)
com.glide.schedule_v2.SchedulerWorkerThread.lambda$process$0(SchedulerWorkerThread.java:188)
com.glide.worker.TransactionalWorkerThread.executeInTransaction(TransactionalWorkerThread.java:35)
com.glide.schedule_v2.SchedulerWorkerThread.process(SchedulerWorkerThread.java:188)
com.glide.schedule_v2.SchedulerWorkerThread.run(SchedulerWorkerThread.java:102)

Cause

 

This error mostly happens after a clone.

This is seen if the column "current reference" is empty for the application record in sys_repo_config(Repository Configuration) table. 

 

 

 

 

 

Resolution


In order to fix this , please do the following steps:

1> Login Git repo. 

2> The repo having issue under master branch check for commit. Like below image.

3>Compare the value of object id under the related link tab "source control branches" of the sys_repo_config record of the application having issue.

4> If they are not same , export xml and add the one from the 2>  as object id for the record having "Is Current = true".

5> Add the same value to the column "current reference" on the record for the application in table sys_repo_config