标签:-- 初始化 hub git init git merge commit use 用户名 --help
本地代码提交到远程仓库:
设置git用户名、邮箱
git config --global user.name xxx git用户名git config --global user.email xxx git邮箱
将项目提交到主分支(master):
git remote rm origin 删除现有远程连接git init 初始化本地仓库touch README.md 创建README.md文件git add . 将修改的文件添加到暂存git commit -m "first commit" 将暂存中的文件提交到本地当前分支git remote add origin https://xxxxxxx.xx/xx/ 将本地仓库连接到远程仓库git push -u origin master 将本地仓库文件push到远程master分支
将主分支代码pull到dev分支:
git branch -a 查看远程全部分支git checkout -b dev origin/dev 在本地创建dev分支并将远程dev分支更新到本地分支git pull origin master --allow-unrelated-histories 将master分支强制更新到当前分支(执行git pull origin master 抛出错误refusing to merge unrelated histories)
错误解决:
命令:git push origin masterfailed to push some refs to ‘https://github.com/CrazyDony/text.git‘hint: Updates were rejected because the tip of your current branch is behindhint: its remote counterpart. Integrate the remote changes (e.g.hint: ‘git pull ...‘) before pushing again.hint: See the ‘Note about fast-forwards‘ in ‘git push --help‘ for details.
原因:自己分支版本低于主版本
解决:
git push -u origin master-fCounting objects: 35, done.Delta compression using up to 4 threads.Compressing objects: 100% (29/29), done.Writing objects: 100% (35/35), 10.15 KiB | 0 bytes/s, done.Total 35 (delta 5), reused 0 (delta 0)To https://github.com/CrazyDony/text.git+ aa70966...f64b22a master -> master (forced update)Branch master set up to track remote branch master from origin. 完成
分支合并:
将dev分支合并到master分支:
git checkout mastergit merge dev
标签:-- 初始化 hub git init git merge commit use 用户名 --help
原文地址:https://www.cnblogs.com/XYYCKL/p/11800108.html