To push a large repository to GitHub is’s one approach to do it step by step: Only some commits at a time.
Here is how I do it using Powershell:
$s = . git --no-pager log --all --no-abbrev-commit --pretty=format:%H,%S,%cI
$s | % {
$ps = $_.Split(",", [System.StringSplitOptions]::RemoveEmptyEntries)
$hash = $ps[0]
$ref = $ps[1]
$date = [datetime]::parse($ps[2])
return (New-Object PSObject -Property @{
Hash = $hash
Ref = $ref
Date = $date
})
} | sort-object Date | where-object {$_.Ref -like "refs/heads/*" } | ForEach-Object {
$ref = $_.Ref
$date = $_.Date
$hash = $_.Hash
write-host "Branch: $ref Date: $($date)"
$outp = . git push --no-verify github "$($hash):$($ref)" 2>&1
if( $lastexitcode -ne 0 -and ($null -eq ($outp | ? { $_ -like "*branch tip is behind*"}))) {
}
$outp | write-host
}
The name of the remote respository is “github”.
This approach pushes each commit of the local repository to remote repo. It starts with the first commit.