首先使用bash here打开git的命令行。然后进入到你的项目当中,首先实例化你的项目。
git init
声明之后,我们可以创建一个将要上传的远程仓库。
git remote add 仓库名 https://gitee.com/
这个地方的网址你必须拥有这个仓库!
然后就可以使用一系列上传
git add .
git commit -m""
git push origin master
进行上传,如果这里报错。
error: failed to push some refs to 'https://gitee.com/tutoucikecmc/gallery'
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.
是远程仓库的内容跟本地仓库的内容不同步,这时候就需要先爬取远程仓库的内容。使用
git pull <远程仓库名>
如果这个时候提醒你没有额外声明一个分支branch的话。
也就是这个
You asked to pull from the remote 'origin', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.
你可以使用
git branch --set-upstream-to=origin/master master
意思是声明origin/master 远程仓库和本地仓库合并默认的master本地仓库分支
接下来就可以使用pull了。使用了pull之后,本地和远程仓库同步,在使用push进行上传即可。
如果你接下来pull出现,refusing to merge unrelated,它意思是两个仓库没有本质联系,他这样是不安全的,你可以使用。
git pull <远程仓库名> --allow-unrelated-histories
这样就可以允许不相关的内容合并,内容同步后,再进行push就好了。
所以这里我推荐你可以利用clone命令进行同步,这样就可以不使用这个命令了,这样做是不安全的。