Several issues with git remote repository linking to existing code

Several issues with git remote repository linking to existing code


  1. If you develop together with other developers, GitLab will grant master permissions to itself in a certain group and create a code base repository. If it is a personal project, just make it personal.
  2. git init
  3. git add .
  4. git commit -m "Initial commit"
  5. git remote add origin http://your_remote_git_server/sample.git
  6. git pull --rebase origin master--rebase is very important, otherwise pull will fail
  7. git push origin master
  8. if appears
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.

firstgit pullfirst step
9. As a resultgit pullappearanceerror: cannot open .git/FETCH_HEAD: Permission denied,则说明.gitThe article has not been changed yet, it has been changed.sudo chmod -R 777 .
git pull

warning: no common commits
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 6 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (6/6), done.
From ssh://git.intra.weibo.com:2222/kuran/krcom-weixin-miniprogram
 * [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

bj-m-207620a:mini_krcom zhangwei37$ 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

  1. git push --set-upstream origin masterAppear
To ssh://git.intra.weibo.com:2222/kuran/krcom-weixin-miniprogram.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'ssh://[email protected]:2222/kuran/krcom-weixin-miniprogram.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.
  1. git pull origin master --allow-unrelated-historiesSolve the problem
  2. git pushAppear
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
  1. git push --set-upstream origin masterAppear
Enumerating objects: 128, done.
Counting objects: 100% (128/128), done.
Delta compression using up to 4 threads
Compressing objects: 100% (124/124), done.
Writing objects: 100% (127/127), 2.33 MiB | 2.53 MiB/s, done.
Total 127 (delta 29), reused 0 (delta 0)
remote: Resolving deltas: 100% (29/29), done.
remote: GitLab: You are not allowed to push code to protected branches on this project.
To ssh://git.intra.weibo.com:2222/kuran/krcom-weixin-miniprogram.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'ssh://[email protected]:2222/kuran/krcom-weixin-miniprogram.git'
  1. Go to the git warehouse to find the administrator to enable master permissions and then entergit push --set-upstream origin masterto solve the problem
  2. .gitignoreDoesn't work, clear cachegit rm -r --cached .

Guess you like

Origin blog.csdn.net/sinat_25259461/article/details/89001743