溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Git如何將建立在本地的倉庫上傳到Gitee中

發(fā)布時間:2020-11-09 15:34:17 來源:億速云 閱讀:242 作者:Leah 欄目:開發(fā)技術

今天就跟大家聊聊有關Git如何將建立在本地的倉庫上傳到Gitee中,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結了以下內容,希望大家根據這篇文章可以有所收獲。

電腦安裝git客戶端、注冊github賬號并登陸

到本地項目文件夾右鍵選擇git bash here

Git如何將建立在本地的倉庫上傳到Gitee中

輸入個人信息(代碼提交者)

git config --global user.name "xxxx" 

git config --global user.email xxxxx@qq.com 

Git如何將建立在本地的倉庫上傳到Gitee中

在本地項目目錄創(chuàng)建本地倉庫

 git init  

輸入命令后項目目錄會有一個隱藏的.git文件夾

上傳所有代碼到本地倉庫

git add.   (注意add后面有個點,與add之間有一空格)

這樣就把代碼上傳到本地倉庫了

 git commit -m "initial commit"

Git如何將建立在本地的倉庫上傳到Gitee中it

在gitee上新建項目,復制https://gitee.com/xxx/xx.git地址

關聯本地倉庫并上傳代碼

git remote add origin https://github.com/Yanyf765/hr_sys.git(上步驟復制的地址)

git push origin master

報錯:

Git如何將建立在本地的倉庫上傳到Gitee中

執(zhí)行命令:

git pull origin master --allow-unrelated-histories

Git如何將建立在本地的倉庫上傳到Gitee中

git 在pull或者合并分支的時候有時會遇到這個界面。可以不管(直接下面3,4步),如果要輸入解釋的話就需要:

1.按鍵盤字母 i 進入insert模式

2.修改最上面那行黃色合并信息,可以不修改

3.按鍵盤左上角"Esc"

4.輸入":wq",注意是冒號+wq,按回車鍵即可

之后就可以成功的pull,push了

Git如何將建立在本地的倉庫上傳到Gitee中

提交到遠程報錯,如下:

Git如何將建立在本地的倉庫上傳到Gitee中

src refspec master does not match any

原因:

本地倉庫為空

解決方法:

使用如下命令 添加文件;

$ git add add.php addok.php conn.php del.php edit.php editok.php ftpsql.sql index.php
 
$ git commit -m "init files"

之后在push過程中出現如下錯誤:

$ git push -u origin master
Warning: Permanently added the RSA host key for IP address 'xx.xx.xxx.xxx' to the list of known hosts.
To git@github.com:hahaha/ftpmanage.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@github.com:hahahah/ftpmanage.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' for details.

提示使用 git pull 之后在 push

使用如下命令解決:

$ git pull --rebase origin master
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From github.com:hahah/ftpmanage
 * branch  master -> FETCH_HEAD
 * [new branch] master -> origin/master
First, rewinding head to replay your work on top of it...
Applying: init files

繼續(xù)push,成功。

Git如何將建立在本地的倉庫上傳到Gitee中

看完上述內容,你們對Git如何將建立在本地的倉庫上傳到Gitee中有進一步的了解嗎?如果還想了解更多知識或者相關內容,請關注億速云行業(yè)資訊頻道,感謝大家的支持。

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI