diff --git a/models/repo.go b/models/repo.go index 58c099d490b0..16b51c47ee3f 100644 --- a/models/repo.go +++ b/models/repo.go @@ -504,6 +504,11 @@ func initRepository(f string, u *User, repo *Repository, initReadme bool, repoLa } if len(fileName) == 0 { + // re-fetch the repository from database before updating it (else it would + // override changes that were done earlier with sql) + if _, err := x.Get(repo); err != nil { + return err + } repo.IsBare = true repo.DefaultBranch = "master" return UpdateRepository(repo)