github绑定远程仓库及将本地代码同步到远程

it2024-10-30  40

创建项目过程 git 初始化仓库的命令是 git init 绑定远程仓库   使用 git remote add origin 'url' 命令将远程仓库与本地仓库绑定。    git remote add origin ********************/TestProject.git         

git pull origin master git add file 命令将改变添加到暂存区 git add . git commit -m “注释”将暂存区内容提交到仓库。 git commit -m "第一次提交" 将本地改变,推送到远程仓库中 使用 git push -u origin master 开始推送  git push origin master

解决方案:保留本地的修改 的改法——通过git stash  

git stash git pull git stash pop

$ git push origin master Username for '*******': ***** To http://1*******.git  ! [rejected]        master -> master (non-fast-forward) error: failed to push some refs to 'http://1*******.git' hint: Updates were rejected because the tip of your current branch is behind hint: 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 pull --rebase origin master

 git push -u origin master

最新回复(0)