git将本地项目添加远程地址

2020-03-27  本文已影响0人  RadishHuang

如果是新的项目大致步骤如下

$ git init
Initialized empty Git repository in /Users/n-321/Desktop/code/lrl-book/.git/
$ git remote add origin git@gitee.com:radishhuang/test-git.git
$ git add .
$ git commit -m "初始化"
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

N-321deMacBook-Pro:test-git n-321$ 
N-321deMacBook-Pro:test-git n-321$ git push --set-upstream origin master
To gitee.com:radishhuang/test-git.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@gitee.com:radishhuang/test-git.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.
N-321deMacBook-Pro:test-git n-321$ 
N-321deMacBook-Pro:test-git n-321$ git pull
warning: no common commits
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 gitee.com:radishhuang/test-git
 * [new branch]      master     -> origin/master
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

N-321deMacBook-Pro:test-git n-321$ 
N-321deMacBook-Pro:test-git n-321$ git pull git@gitee.com:radishhuang/test-git.git master --allow-unrelated-histories
From gitee.com:radishhuang/test-git
 * branch            master     -> FETCH_HEAD
Merge made by the 'recursive' strategy.
 README.en.md | 36 ++++++++++++++++++++++++++++++++++++
 README.md    | 37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 73 insertions(+)
 create mode 100644 README.en.md
 create mode 100644 README.md
N-321deMacBook-Pro:test-git n-321$ 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

N-321deMacBook-Pro:test-git n-321$ git push --set-upstream origin master
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 12 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 10.50 MiB | 2.05 MiB/s, done.
Total 5 (delta 0), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-3.8]
To gitee.com:radishhuang/test-git.git
   630bef5..6fc3e69  master -> master

总结:

上一篇 下一篇

猜你喜欢

热点阅读