Command line instructions
1.Git global setup
git config --global user.name "xxx"
git config --global user.email "xxxxxxx"
2.Create a new repository
git clone git@gitlab.com:xxx/xxx.git
cd baoding
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
3.Existing folder
cd existing_folder
git init
git remote add origin git@gitlab.com:xxx/xxx.git
git add .
git commit -m "Initial commit"
git push -u origin master
4.Existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin git@gitlab.com:xxx/xxx.git
git push -u origin --all
git push -u origin --tags
本地git项目推送到远程。首先在远程上新建一个项目,推送命令发出后,若出现: failed to push some refs to git 错误,主要原因是github中的README.md文件不在本地代码目录中,因此,可通过如下命令进行代码合并(pull=fetch+merge):
git remote add origin git@gitlab.com:xxx/xxx.git
git pull --rebase origin master
执行完此代码后可以看到本地代码库多了README.MD文件,此时,再执行语句:
$ git push -u origin master
5.git文件太大上传不了
1 提交后提示
fatal: recursion detected in die handler
问题原因:
问题原因是http.postBuffer默认上限为1M所致。在git的配置里将http.postBuffer变量改大一些即可,比如将上限设为500M:
git config --global http.postBuffer 524288000
在哪里执行以上命令呢?
打开git bash命令行工具。
注意要加上–global。网上很多资料都没加这个参数。不加执行的话会报以下错误的:
error:could not lock config file .git/config: no such file or directory.
使用TortoiseGit
右键TortoiseGit–settings–Git–Edit systemwide gitconfig–把postBuffer的值修改为524288000
6.git克隆大文件出错
使用
git clone 地址 --depth=1