Skip to content

Instantly share code, notes, and snippets.

@zhoufankai
Last active May 16, 2017 09:05
Show Gist options
  • Save zhoufankai/69fea27086735d197c227340372b15a7 to your computer and use it in GitHub Desktop.
Save zhoufankai/69fea27086735d197c227340372b15a7 to your computer and use it in GitHub Desktop.
git先本地初始化然后在push
git init
git remote add origin ssh://git@ip:8800/coz/coz3.git
git fetch
git add .
git commit
git pull origin master
# git rebase origin
git push origin master
途中出现2个问题
问题1
remote: GitLab: You are not allowed to push code to protected branches
解决
You need to be a owner or have a master permission for the initial push.
问题2
$ git push origin master
To http://ip:8800/coz/coz3.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'http://origin:8800/coz/coz3.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.
解决:
you should do the 'git pull origin master' command before you push.
问题3:
当我原地址更改的时候,我建了新的地址,加上地址后,我想把代码传到新地址,但是并不能传上去。
remote: GitLab: You are not allowed to push code to protected branches on this roject.
To http://139.196.194.74:8800/coz_server/coz3.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'http://139.196.194.74:8800/coz_server/coz3.it'
解决:
修改了branch里的project settings, 增加deverlop用户可以push
问题4:
我在用tortoiseGit的时候,总是密码错误。
解决
我把tortoiseGit远程连接的设置改为了http地址,就很准了。
@zhoufankai
Copy link
Author

查看git的用户

git config --list

#配置用户
$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment