git远程仓库链接现有代码的若干问题

git远程仓库链接现有代码的若干问题


  1. 如果和其他开发者共同开发,则gitlab在某群组里向自己开通master权限,创建代码库repository。如果是个人项目,直接搞成个人的。
  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 非常重要,否则pull失败
  7. git push origin master
  8. 如果出现
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.

git pull一下
9. 如果git pull出现error: cannot open .git/FETCH_HEAD: Permission denied,则说明.git文件夹里没有更改权限,执行sudo chmod -R 777 .
9. 然后在执行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 master 出现
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://git@git.intra.weibo.com: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-histories 解决问题
  2. 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 master出现
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://git@git.intra.weibo.com:2222/kuran/krcom-weixin-miniprogram.git'
  1. 到git仓库找管理员开通master权限然后在输入git push --set-upstream origin master解决问题
  2. .gitignore不起作用,清除下缓存git rm -r --cached .
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值