失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > 【git】使用git链接远程gitee仓库并提交

【git】使用git链接远程gitee仓库并提交

时间:2019-03-17 22:44:49

相关推荐

【git】使用git链接远程gitee仓库并提交

前提

已经在本地下载好git,在gitee注册好了账户(绑定了邮箱)并且新建好了仓库,假如说仓库名字叫做test

目的

现在电脑上面有一个文件夹名字叫做file,我要做的事情:把file文件夹内部的file1文件夹、file2文件夹以及他们内部的各种文件上传到gitee新建的那个test仓库里面:

步骤

在file文件夹内部的空白位置按住shift+右键(注意一定要按住shift!!!):

选择“在此处打开powershell窗口”

然后就进入了命令行界面(控制台界面/小黑框)首先进行全局配置,输入:

双引号内部的为用户名(gitee带汉字的那个名字)、邮箱(gitee绑定的那个)然后输入:

git init

git add .

git commit -m "随便说点啥都行,自己认识作为每次提交的标识"

git remote add origin https:/yourname/test.git

git push -u origin "master"

第四行命令后面的网址,可以在你的仓库这里找到其中git add . 的意思是把当前目录下的(即file1、file2)所有内容都加到缓存区里;git commit 是把缓存区内的东西都提交到本地仓库;git remote add origin https://…这一句是链接到远程仓库,第一次需要写,第二次之后就不用链接了;git push 这句是把本地仓库的内容推送到远程仓库中去

可能出现的bug:

在git push 之后不成功,显示这样的:

PS > git push -u origin "master"To /username/test.git! [rejected] master -> master (fetch first)error: failed to push some refs to '/username/test.git'hint: Updates were rejected because the remote contains work that you dohint: not have locally. This is usually caused by another repository pushinghint: to the same ref. You may want to first integrate the remote changeshint: (e.g., 'git pull ...') before pushing again.hint: See the 'Note about fast-forwards' in 'git push --help'

原因是本地仓库内容跟远程仓库内容不一致,出现这种情况的原因一般是因为,在新建test仓库的时候勾选了一些选项,导致仓库建起来里面并不是空的,而是有一些.md文件

解决方法:

通过如下命令进行代码合并:

git pull --rebase origin master

然后再运行git push 那条命令,就ok辣!

如果觉得《【git】使用git链接远程gitee仓库并提交》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。