Skip to content

Commit bdb491e

Browse files
zeripathmrsdizzietechknowlogick
authored
Push HEAD instead of master when initialising repositories (#13719) (#13740)
* Push HEAD instead of master when initialising repositories It is possible on modern gits to change the initial branch to something other than master. This breaks initialising repositories because we assume that the initial branch is going to be master unless specifically changed. This PR simply bypasses this issue by pushing the HEAD rather than the master branch. Signed-off-by: Andrew Thornton <[email protected]> * Update modules/repository/init.go Co-authored-by: mrsdizzie <[email protected]> Co-authored-by: mrsdizzie <[email protected]> Co-authored-by: techknowlogick <[email protected]> Co-authored-by: mrsdizzie <[email protected]> Co-authored-by: techknowlogick <[email protected]>
1 parent a82c7d4 commit bdb491e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

modules/repository/init.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,10 @@ func initRepoCommit(tmpPath string, repo *models.Repository, u *models.User, def
162162
defaultBranch = setting.Repository.DefaultBranch
163163
}
164164

165-
if stdout, err := git.NewCommand("push", "origin", "master:"+defaultBranch).
165+
if stdout, err := git.NewCommand("push", "origin", "HEAD:"+defaultBranch).
166166
SetDescription(fmt.Sprintf("initRepoCommit (git push): %s", tmpPath)).
167167
RunInDirWithEnv(tmpPath, models.InternalPushingEnvironment(u, repo)); err != nil {
168-
log.Error("Failed to push back to master: Stdout: %s\nError: %v", stdout, err)
168+
log.Error("Failed to push back to HEAD: Stdout: %s\nError: %v", stdout, err)
169169
return fmt.Errorf("git push: %v", err)
170170
}
171171

0 commit comments

Comments
 (0)