- 把本地文件夹变成git 仓库
git init
- 本地代码提交
git add .
git commit -m "提交说明"
- 远程分支需要配置
1.先在github上新建个reposity
2. 把本地的公钥加到github
- 添加远程仓库
git remote add origin(远程仓库名) git@github.com:test/branchName.git(自己的github clone 地址)
必须加 add 参数
git remote origin(远程仓库名) git@github.com:test/branchName.git(自己的github clone 地址)
报错如下: error: Unknown subcommand: github_python usage: git remote [-v | --verbose] or: git remote add [-t <branch>] [-m <master>] [-f] [--tags | --no-tags] [--mirror=<fetch|push>] <name> <url> or: git remote rename <old> <new> or: git remote remove <name> or: git remote set-head <name> (-a | --auto | -d | --delete | <branch>) or: git remote [-v | --verbose] show [-n] <name> or: git remote prune [-n | --dry-run] <name> or: git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...] or: git remote set-branches [--add] <name> <branch>... or: git remote get-url [--push] [--all] <name> or: git remote set-url [--push] <name> <newurl> [<oldurl>] or: git remote set-url --add <name> <newurl> or: git remote set-url --delete <name> <url> -v, --verbose be verbose; must be placed before a subcommand
- 如果远程分支有文件必须先 git fetch 和 git merge
git fetch origin master
git merge --allow-unrelated-histories origin/master
两个不相关的分支merge会报错,必须加 --allow-unrelated-histories
否则会报错 fatal: refusing to merge unrelated histories
- 把本地提交推送到远端分支
git push origin master
如果你提交的单个文件有大于100M,会出现如下报错:
Enumerating objects: 226, done. Counting objects: 100% (226/226), done. Delta compression using up to 8 threads Compressing objects: 100% (205/205), done. Connection reset by 13.229.188.59 port 22 fatal: sha1 file '<stdout>' write error: Broken pipe/s fatal: the remote end hung up unexpectedly fatal: the remote end hung up unexpectedly
解决办法在本地git bash中执行:git config http.postBuffer 524288000
把提交文件大小的上限设置大点就可以了,改成500M
然后再git push origin master 就没有报错了,push完之后再刷新一下github
页面就可以看到提交的文件了。
网友评论