1. 程式人生 > >將本地的git專案推送到gitHub中的操作

將本地的git專案推送到gitHub中的操作

touch README
git add README
git commit -m 'first commit'
git push -u origin master


上面處理的連結: http://www.open-open.com/lib/view/open1366080269265.html


這樣就可以進行新增操作,當然首先你得有SSH的KEY才能完成這一步,那麼如何來建立SSHkey呢?

➜  test git:(master) git push -u origin master
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
➜  test git:(master) git push -u origin master
To github.com:lmzqm/springboottest.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to '
[email protected]
:lmzqm/springboottest.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.


悲劇,又遇到錯誤了,好吧!繼續破解它

上面說的大體意思是叫你要先拉取遠端的資訊,然後在進行推送的操作
好吧!那就先拉取把!

test git:(master) git pull origin master
warning: no common commits
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (4/4), done.
Unpacking objects: 100% (5/5), done.
remote: Total 5 (delta 0), reused 0 (delta 0), pack-reused 0
From github.com:lmzqm/springboottest
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> origin/master
fatal: refusing to merge unrelated histories


我擦!又出現錯誤!
好吧!先看看到底是什麼錯誤:
fatal: refusing to merge unrelated histories
致命的:拒絕合併不相關的歷史

看的很清楚了吧!不允許合併,沒有共同祖先的分支

--allow-unrelated-histories
  By default, git merge command refuses to merge histories that do not share a common ancestor.

需要加上這個就可以搞定了

git pull --allow-unrelated-histories origin master

上面處理的連結:https://github.com/doggy8088/Learn-Git-in-30-days/issues/31


From github.com:lmzqm/springboottest
 * branch            master     -> FETCH_HEAD
Auto-merging .gitignore
CONFLICT (add/add): Merge conflict in .gitignore
Automatic merge failed; fix conflicts and then commit the result.


這樣就可以將遠端的專案拉取過來了,報衝突了,夠倒黴的
git status 看看是那些檔案衝突了
Unmerged paths:
  (use "git add <file>..." to mark resolution)
        both added:      .gitignore

還行,就一個
vim .gitignore 處理衝突
然後 git commit -a -m '處理衝突' 
-a 是all的意思
-m 是 message的意思

重新提交
然後就可以執行:
git push -u origin master  //這裡的-u主要是關聯
➜  test git:(master) git push -u origin master
Counting objects: 70, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (55/55), done.
Writing objects: 100% (70/70), 393.54 KiB | 0 bytes/s, done.
Total 70 (delta 3), reused 0 (delta 0)
remote: Resolving deltas: 100% (3/3), done.
To github.com:lmzqm/springboottest.git
   9bf9a98..7176128  master -> master
Branch master set up to track remote branch master from origin.


這裡就說明已經成功了,哈哈

相關推薦

本地git專案gitHub操作

touch README git add README git commit -m 'first commit' git push -u origin master 上面處理的連結: http://www.open-open.com/lib/view/open1366080269265.html 這樣就可以進

使用git命令本地項目到遠程倉庫

替換 readme.md 項目 sage mage message 如何 執行 寫實 將本地項目推送到遠程倉庫 這裏先放一張圖, 有助於理解git命令 1. 在GitHub上新建一個倉庫 註意不要勾選自動生成README.md文件, 否則會產生某些問題, README.m

Git基本使用方法——本地建立一個 git 專案到遠端空倉庫

步驟 新建資料夾 mkdir newProject cd new Project 把一個資料夾初始化成一個本地 git 倉庫 倉庫和資料夾的區別在於倉庫下有一個隱藏的 .git

git本地分支程式碼至GitLab遠端

0.gitlab上已存在專案 前提,我們gitlab伺服器上已經有專案了 1.初始化本地倉庫 git init 2.方式一:更新遠端倉庫地址,<URL>更換為新的url地址。 gi

利用tortoisegit本地項目至gitlab指定group

這一 sig 指定 因此 group tlab 重復 管理 gin 直接上步驟: 1、在gitlab上新建group,如下圖,右上角有個 "+",點擊可以選擇新建project、group、snippet。然後取名,此名字在gitlab上具有唯一性,因此可能會提示重復,比如

本地repo映象到遠端gerrit伺服器

1、獲取遠端供應商的repo映象 repo init --mirror -u ssh://[email protected]$host_name:29418/manifests -b xx_branch --repo-url=ssh://[email protected]$h

本地git倉庫到伺服器自建的git倉庫實現目錄檔案同步教程[自整理]

1.首先,先在伺服器上安裝git,如果有git的話就不用走這一步了 yum安裝git [[email protected] ~]# cd src/ [[email protected] src]# wget http://dl.fedoraproj

Git本地專案github

【部落格園cnblogs筆者m-yb原創,轉載請加本文部落格連結,筆者github: https://github.com/mayangbo666,公眾號aandb7,QQ群927113708】  https://www.cnblogs.com/m-yb/p/10162384.html &nbs

git本地專案到遠端空倉庫

1、登入git賬戶,新建一個程式碼倉庫 2、進入自己要推送的專案目錄下然後git init 3、將本地和遠端廠庫關聯起來 git remote add origin [email protected]:地址 4、將原生代碼推送

如何本地的檔案或者專案到遠端倉庫github

如果你需要使用git將本地的專案或者檔案推送到github,那麼你就需要安裝一個git客戶端,並且註冊一個github的賬號。 如何安裝git客戶端在windows筆記本,可以看我的這篇文章git客戶端下載和安裝以及配置,你只需要一路next,並且安裝完客戶端以

使用git命令本地專案到遠端倉庫

推送前需要在遠端倉庫建立好repository和project,之後會生成專案的url,比如 [email protected]:finger-shoot/shoot-photographe

git本地專案到遠端

在團隊開發做專案和版本控制時,免不了要使用git,如果已經在本地和oschina.net建立了倉庫,那我們只需要按時將專案推送到遠端即可,開始吧: 1.初始化將自己的專案放入快取區 git init git add ....(專案資料夾/檔案) 2.提交專案到本地的倉庫 g

GitHub學習(三):Phpstormgit使用(1)--建立本地倉庫與

這段時間在學php的laravel框架,用的開發軟體是xampp建站整合軟體和phpstorm,前幾天做完了表單處理工程,因為上班和在家用的是兩臺電腦,所以需要用github來儲存程式碼,在這裡記錄下phpstorm中的git使用,以免以後忘了。 我已經寫了一部分的程式碼的工程,我現在的第一步就是

創建局域網內遠程git倉庫,並本地倉庫push到遠程倉庫

目錄 html fatal targe images rem url already tle 轉自原文 創建局域網內遠程git倉庫,並將本地倉庫push推到遠程倉庫中 1. 先遠程登錄局域網內服務器 2. 在服務器裏 切換到某個文件夾下, 然後新建一個

git push 本地專案到遠端分支

大家有的時候,會在本地新建專案,這裡說一下在本地專案建立本地GIT中倉庫,然後推到遠端倉庫的步驟 1.在本地專案的資料夾下,GIT中倉庫初始化   初始化本地的Git倉庫    2。 將本地檔案索引新增至混帳庫中 3。 4。

git在遠端伺服器建立專案原生代碼到伺服器上

1.進入到遠端伺服器 ssh name (name:遠端伺服器地址) 2.進入以後新建一個空的倉庫 git init --bare name (name:倉庫的名稱) 3.退出遠端伺服器 exit 4.到需要提交的檔案的目錄裡面(命令:cd) 5.在需要提交的檔

git 本地專案到遠端倉庫(或者倉庫分支)Window版-01

初始化專案git init 確保安裝了git 在專案根目錄下進入 git命令列 使用git init 命令 使用 git add .命令 使用 git commit

在window10系統下使用git命令本地倉庫檔案到github遠端倉庫的步驟

準備工作:1.系統安裝好git軟體                    2.去git官網註冊賬號並建立遠端倉庫(相關教程請百度吧),從而得到遠端倉庫地址 開始:       1.在你的電腦上建立一個檔案目錄(檔名字自定義)       2.開啟git命令客戶端視窗(

Git本地專案到遠端倉庫

有時候,我們需要把本地的專案推送到遠端Git倉庫(GitHub或者自己搭建的GitLab)中,可以通過以下幾個步驟來實現: 1、新建遠端倉庫 我們需要在遠端git服務端新建一個Git倉庫來儲存管理本地的專案,有兩種方法,比較簡單,如下: 1. 通過G

git 更新遠端程式碼到本地原生代碼到遠端。

我們在多臺電腦上開發一個專案的時候,需要經常修改提交內容並在另一臺電腦上更新遠端最新的程式碼,今天看了一下如何從遠端程式碼倉庫獲取更新到本地。 檢視遠端分支 使用如下命令可以檢視遠端倉庫(