赞
踩
先安装git,网上随便找一个安装。
打开IntelliJ IDEA点击菜单File下的Settings,找到git.exe路径
点击ok会弹出git的版本,因为我已经安装过,所以点击测试下面显示git版本
VCS下选择Create Git Repository
选择需要创建Git仓库的项目文件
操作之后我们发现文件都会变红,是因为文件还没有上传到仓库(git上传之后会变绿)
右击项目文件,选择git,选择Manage Remotes
设置名字,输入远程仓库地址,点击OK后输入用户名密码
可以用SSH地址或者HTTPS地址,以HTTPS地址举例,点击克隆,复制远程仓库地址
HTTPS用户名密码在这里
输入HTTPS的用户名和密码后,与远程仓库连接成功
Commit ,下面可以添加备注信息方便区分
Commit 之后就可以Push
error: failed to push some refs to ‘https://codehub.devcloud.cn-north-4.huaweicloud.com/fkz-dsshwzJavaWebsjk-CH00001/javaweb.git’
hint: Updates were rejected because the remote contains work that you do
To https://codehub.devcloud.cn-north-4.huaweicloud.com/fkz-dsshwzJavaWebsjk-CH00001/javaweb.git
hint: not have locally. This is usually caused by another repository pushing
! refs/heads/master:refs/heads/master [rejected] (fetch first)
Done
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.
解决方法: 要先pull
没有分支,按Ctrl + F5 更新分支
更新之后就可以正常显示分支了
POST git-upload-pack (294 bytes)
From https://codehub.devcloud.cn-north-4.huaweicloud.com/fkz-dsshwzJavaWebsjk-CH00001/javaweb
* branchmaster-> FETCH_HEAD
= [up to date]master-> origin/master
refusing to merge unrelated histories
拒绝合并不相关的历史
解决方法:
git pull origin master --allow-unrelated-histories
注意:不要上传到远程仓库之后删除完远程仓库的代码再用这个命令,我先自己做完再删除掉远程仓库里的代码用的这个命令,项目内容都被删了,和远程仓库的内容一样了!!!
remote: 无效的用户名格式,请输入正确的用户名[账户名/用户名]!
remote: 具体可以点击 代码托管首页-设置我的HTTPS密码 查看
remote: 如果您设置了凭证管理[credential.helper], 请先清理.
repository ‘https://codehub.devcloud.cn-north-4.huaweicloud.com/fkz-dsshwzJavaWebsjk-CH00001/javaweb.git/’ not found
这是因为用户名密码错误,而每次凭证自动登录没有重新输入的机会,需要修改凭证里的用户名和密码或者删除凭证。
解决方法:打开凭据管理器进行修改
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。