public string PushCmd(string remote, string fromBranch, string toBranch,
ForcePushOptions force, bool track, int recursiveSubmodules)
{
remote = remote.ToPosixPath();
// This method is for pushing to remote branches, so fully qualify the
// remote branch name with refs/heads/.
fromBranch = FormatBranchName(fromBranch);
toBranch = GitCommandHelpers.GetFullBranchName(toBranch);
if (String.IsNullOrEmpty(fromBranch) && !String.IsNullOrEmpty(toBranch))
fromBranch = "HEAD";
if (toBranch != null) toBranch = toBranch.Replace(" ", "");
var sforce = GitCommandHelpers.GetForcePushArgument(force);
var strack = "";
if (track)
strack = "-u ";
var srecursiveSubmodules = "";
if (recursiveSubmodules == 1)
srecursiveSubmodules = "--recurse-submodules=check ";
if (recursiveSubmodules == 2)
srecursiveSubmodules = "--recurse-submodules=on-demand ";
var sprogressOption = "";
if (GitCommandHelpers.VersionInUse.PushCanAskForProgress)
sprogressOption = "--progress ";
var options = String.Concat(sforce, strack, srecursiveSubmodules, sprogressOption);
if (!String.IsNullOrEmpty(toBranch) && !String.IsNullOrEmpty(fromBranch))
return String.Format("push {0}\"{1}\" {2}:{3}", options, remote.Trim(), fromBranch, toBranch);
return String.Format("push {0}\"{1}\" {2}", options, remote.Trim(), fromBranch);
}