Git 本地仓库与远程仓库的关联

由于我先创建了本地代码,再创建仓库。最后要将本地仓库与远程仓库关联

操作步骤如下:

git branch
git remote add origin https://gitee.com/s.git
git remote -v
git push origin master
git pull --rebase origin master
git push
git push --set-upstream origin master
root@iZ6wef8e9r2zp7019pbq5mZ:/var/www/html/magento_shoes# git branch
* master
root@iZ6wef8e9r2zp7019pbq5mZ:/var/www/html/magento_shoes# git remote add origin https://gitee.com/s.git
root@iZ6wef8e9r2zp7019pbq5mZ:/var/www/html/magento_shoes# git remote -v
origin  https://gitee.com/ysqphp/magento_shoes.git (fetch)
origin  https://gitee.com/ysqphp/magento_shoes.git (push)
root@iZ6wef8e9r2zp7019pbq5mZ:/var/www/html/magento_shoes# git push origin master
Username for 'https://gitee.com': 421072757@qq.com
Password for 'https://421072757@qq.com@gitee.com':
remote: 421072757@qq.com: Incorrect username or password (access token)
fatal: Authentication failed for 'https://gitee.com/ysqphp/magento_shoes.git/'
root@iZ6wef8e9r2zp7019pbq5mZ:/var/www/html/magento_shoes# git push origin master
Username for 'https://gitee.com': 421072757@qq.com
Password for 'https://421072757@qq.com@gitee.com':
To https://gitee.com/ysqphp/magento_shoes.git
 ! [rejected]            master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/ysqphp/magento_shoes.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
root@iZ6wef8e9r2zp7019pbq5mZ:/var/www/html/magento_shoes# git pull --rebase origin master
Username for 'https://gitee.com': 421072757@qq.com
Password for 'https://421072757@qq.com@gitee.com':
warning: no common commits
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), done.
From https://gitee.com/ysqphp/magento_shoes
 * branch                master     -> FETCH_HEAD
 * [new branch]          master     -> origin/master
First, rewinding head to replay your work on top of it...
Applying: 初始化网站信息
root@iZ6wef8e9r2zp7019pbq5mZ:/var/www/html/magento_shoes# git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master

root@iZ6wef8e9r2zp7019pbq5mZ:/var/www/html/magento_shoes# git push --set-upstream origin master
Username for 'https://gitee.com': 421072757@qq.com
Password for 'https://421072757@qq.com@gitee.com':
Counting objects: 72136, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (46231/46231), done.
Writing objects: 100% (72136/72136), 90.81 MiB | 265.00 KiB/s, done.
Total 72136 (delta 17121), reused 72134 (delta 17121)
remote: Resolving deltas: 100% (17121/17121), done.
remote: Powered by GITEE.COM [GNK-5.0]
To https://gitee.com/ysqphp/magento_shoes.git
   0ddbaeb78..b1c44786e  master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
root@iZ6wef8e9r2zp7019pbq5mZ:/var/www/html/magento_shoes# git branch -a
* master
  remotes/origin/master
root@iZ6wef8e9r2zp7019pbq5mZ:/var/www/html/magento_shoes#

本文参考:
https://www.cnblogs.com/tudoujun/p/11599921.html

Leave a comment

您的电子邮箱地址不会被公开。 必填项已用 * 标注