【git】使用git链接远程gitee仓库并提交
生活随笔
收集整理的這篇文章主要介紹了
【git】使用git链接远程gitee仓库并提交
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
前提
已經(jīng)在本地下載好git,在gitee注冊好了賬戶(綁定了郵箱)并且新建好了倉庫,假如說倉庫名字叫做test
目的
- 現(xiàn)在電腦上面有一個文件夾名字叫做file,我要做的事情:把file文件夾內(nèi)部的file1文件夾、file2文件夾以及他們內(nèi)部的各種文件上傳到gitee新建的那個test倉庫里面:
步驟
選擇“在此處打開powershell窗口”
然后就進入了命令行界面(控制臺界面/小黑框)
雙引號內(nèi)部的為用戶名(gitee帶漢字的那個名字)、郵箱(gitee綁定的那個)
git init
git add .
git commit -m "隨便說點啥都行,自己認識作為每次提交的標識"
git remote add origin https:gitee.com/yourname/test.git
git push -u origin "master"
- 第四行命令后面的網(wǎng)址,可以在你的倉庫這里找到
- 其中git add . 的意思是把當前目錄下的(即file1、file2)所有內(nèi)容都加到緩存區(qū)里;
- git commit 是把緩存區(qū)內(nèi)的東西都提交到本地倉庫;
- git remote add origin https://…這一句是鏈接到遠程倉庫,第一次需要寫,第二次之后就不用鏈接了;
- git push 這句是把本地倉庫的內(nèi)容推送到遠程倉庫中去
可能出現(xiàn)的bug:
在git push 之后不成功,顯示這樣的:
PS > git push -u origin "master"To https://gitee.com/username/test.git! [rejected] master -> master (fetch first) error: failed to push some refs to 'https://gitee.com/username/test.git' 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'原因是本地倉庫內(nèi)容跟遠程倉庫內(nèi)容不一致,出現(xiàn)這種情況的原因一般是因為,在新建test倉庫的時候勾選了一些選項,導致倉庫建起來里面并不是空的,而是有一些.md文件
- 解決方法:
通過如下命令進行代碼合并:
git pull --rebase origin master
然后再運行git push 那條命令,就ok辣!
總結(jié)
以上是生活随笔為你收集整理的【git】使用git链接远程gitee仓库并提交的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 多层卷积后感受野的计算
- 下一篇: MBA心路历程第一天 —— 开始行动