diff --git a/models/repo.go b/models/repo.go
index 34b7cd835..201954210 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -1307,9 +1307,7 @@ func ForkRepository(u *User, oldRepo *Repository) (*Repository, error) {
             }
         }
     
-        if err = sess.Commit(); err != nil {
-            return nil, err
-        }
+        
     
         if u.IsOrganization() {
             t, err := u.GetOwnerTeam()
@@ -1335,7 +1333,16 @@ func ForkRepository(u *User, oldRepo *Repository) (*Repository, error) {
         if err = NewRepoAction(u, repo); err != nil {
             log.Error(4, "NewRepoAction: %v", err)
         }
-   
+        
+        if _, err = sess.Exec(
+            "UPDATE `repository` SET num_forks = num_forks + 1 WHERE id = ?", oldRepo.Id); err != nil {
+            sess.Rollback()
+            return nil, err
+        }
+        
+        if err = sess.Commit(); err != nil {
+            return nil, err
+        }
     
         repoPath := RepoPath(u.Name, repo.Name)
         _, stderr, err := process.ExecTimeout(10*time.Minute,
@@ -1350,5 +1357,6 @@ func ForkRepository(u *User, oldRepo *Repository) (*Repository, error) {
         }
     
         return repo, nil
+   
 
 }
diff --git a/routers/repo/repo.go b/routers/repo/repo.go
index dac0c48b3..8b18eb25b 100644
--- a/routers/repo/repo.go
+++ b/routers/repo/repo.go
@@ -219,11 +219,17 @@ func Action(ctx *middleware.Context) {
 		err = models.StarRepo(ctx.User.Id, ctx.Repo.Repository.Id, false)
         case "fork":
                 repo, error := models.ForkRepository(ctx.User, ctx.Repo.Repository)
-                log.Info("Tried to fork a repo!")
-                log.Info("Repo thing is " + repo.Name)
                 if error != nil {
+                    log.Error(4, "Action(%s): %v", ctx.Params(":action"), error)
+                    ctx.JSON(200, map[string]interface{}{
+                        "ok":  false,
+                        "err": error.Error(),
+                    })
+                    return
+                }
+                if error == nil {
+                        ctx.Redirect(setting.AppSubUrl + "/" + repo.Owner.Name + "/" + repo.Name)
                         
-                        ctx.Redirect(setting.AppSubUrl + "/" + ctx.User.Name + "/" + repo.Name)
                         return
                 }
 	case "desc":