日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Git-将已有的项目转换为GIT项目托管到 GITHUB 仓库

發(fā)布時間:2025/3/21 编程问答 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Git-将已有的项目转换为GIT项目托管到 GITHUB 仓库 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

文章目錄

  • 概述
  • 步驟
    • 1.GIT軟件安裝
    • 2.初始化本地maven項目為 Git 項目
    • 3.將所有文件放進(jìn)新的本地 git 倉庫
    • 4. 將添加的文件提交到倉庫
    • 5. GitHub上創(chuàng)建項目 ,copy項目地址
    • 6. 回到命令行終端界面,將本地倉庫關(guān)聯(lián)到遠(yuǎn)程倉庫
    • 7. 提交代碼到 GitHub 倉庫
    • 8. Github上查看項目
    • Github提示信息
    • 9. 在Spring Tool Suite中連接GITHUB
  • 另外一個Java項目托管到github上的完整操作

概述

打算將SpringMaster項目托管到GitHub,方便查閱

最終效果如下:


步驟

1.GIT軟件安裝

現(xiàn)在并安裝GIT

我們這里使用通過命令行的方式將本地項目托管到GITHUB。


2.初始化本地maven項目為 Git 項目

本地項目目錄: D:\workspace\workspace-sts\SpringMaster

打開GIT BASH,進(jìn)入到項目所在目錄

執(zhí)行命令

$ git init

此時會在目錄中創(chuàng)建一個 .git 隱藏文件夾,如下


3.將所有文件放進(jìn)新的本地 git 倉庫

$ git add .

如果你本地已經(jīng)有 .gitignore 文件,會按照已有規(guī)則過濾不需要添加的文件。如果不想要添加所有文件,可以把 . 符號換成具體的文件名


4. 將添加的文件提交到倉庫

git commit -m "Initial commit"


5. GitHub上創(chuàng)建項目 ,copy項目地址

創(chuàng)建過程省略,最后如下所示:

https://github.com/yangshangwei/SpringMaster.git 復(fù)制倉庫地址


6. 回到命令行終端界面,將本地倉庫關(guān)聯(lián)到遠(yuǎn)程倉庫

Mr.Yang@Mr MINGW64 /d/workspace/workspace-sts/SpringMaster (master) $ git remote add origin https://github.com/yangshangwei/SpringMaster.gitMr.Yang@Mr MINGW64 /d/workspace/workspace-sts/SpringMaster (master) $ git remote -v origin https://github.com/yangshangwei/SpringMaster.git (fetch) origin https://github.com/yangshangwei/SpringMaster.git (push)

通過 git remote -v命令查看結(jié)果


7. 提交代碼到 GitHub 倉庫

Mr.Yang@Mr MINGW64 /d/workspace/workspace-sts/SpringMaster (master) $ git push -u origin master Counting objects: 590, done. Delta compression using up to 4 threads. Compressing objects: 100% (574/574), done. Writing objects: 100% (590/590), 150.56 KiB | 0 bytes/s, done. Total 590 (delta 180), reused 0 (delta 0) remote: Resolving deltas: 100% (180/180), done. To https://github.com/yangshangwei/SpringMaster.git* [new branch] master -> master Branch master set up to track remote branch master from origin.


8. Github上查看項目


Github提示信息

倉庫創(chuàng)建成功后,Github如下提示信息,可以指導(dǎo)我們將項目托管到GITHUB 倉庫

…or create a new repository on the command lineecho "# SpringMaster" >> README.md git init git add README.md git commit -m "first commit" git remote add origin https://github.com/yangshangwei/SpringMaster.git git push -u origin master…or push an existing repository from the command linegit remote add origin https://github.com/yangshangwei/SpringMaster.git git push -u origin master…or import code from another repository You can initialize this repository with code from a Subversion, Mercurial, or TFS project.

9. 在Spring Tool Suite中連接GITHUB

Windows—Show View選擇Git Repositories

選擇 Add an existing local Git Repository to this view

選擇本地的GIT項目

切換到GIT視圖 或者Spring視圖 都可以看到了

文件操作,右鍵 Team


或者下載一個GitHub Desktop

File-Add local Repository

如下

選擇你要操作的項目即可


或者直接使用命令行的方式最為方便。



另外一個Java項目托管到github上的完整操作

打開GitBash

Mr.Yang@Mr MINGW64 ~ $ cd d:Mr.Yang@Mr MINGW64 /d $ cd workspace/ws-java-base/commonUtils/Mr.Yang@Mr MINGW64 /d/workspace/ws-java-base/commonUtils $ git init Initialized empty Git repository in D:/workspace/ws-java-base/commonUtils/.git/Mr.Yang@Mr MINGW64 /d/workspace/ws-java-base/commonUtils (master) $ git add .Mr.Yang@Mr MINGW64 /d/workspace/ws-java-base/commonUtils (master) $ git commit -m "Intial commit" [master (root-commit) 42fb8f6] Intial commit18 files changed, 438 insertions(+)create mode 100644 .classpathcreate mode 100644 .projectcreate mode 100644 .settings/org.eclipse.core.resources.prefscreate mode 100644 .settings/org.eclipse.jdt.core.prefscreate mode 100644 .settings/org.eclipse.m2e.core.prefscreate mode 100644 pom.xmlcreate mode 100644 src/main/java/com/artisan/commonUtils/App.javacreate mode 100644 src/main/java/com/artisan/commonUtils/getPath/PathUtil.javacreate mode 100644 src/main/java/com/artisan/commonUtils/getPath/PathUtilDemo.javacreate mode 100644 src/main/java/com/artisan/commonUtils/mail/MailServer.propertiescreate mode 100644 src/main/java/com/artisan/commonUtils/mail/SendEmailUtil.javacreate mode 100644 src/test/java/com/artisan/commonUtils/AppTest.javacreate mode 100644 target/classes/com/artisan/commonUtils/App.classcreate mode 100644 target/classes/com/artisan/commonUtils/getPath/PathUtil.classcreate mode 100644 target/classes/com/artisan/commonUtils/getPath/PathUtilDemo.classcreate mode 100644 target/classes/com/artisan/commonUtils/mail/MailServer.propertiescreate mode 100644 target/classes/com/artisan/commonUtils/mail/SendEmailUtil.classcreate mode 100644 target/test-classes/com/artisan/commonUtils/AppTest.classMr.Yang@Mr MINGW64 /d/workspace/ws-java-base/commonUtils (master) $ git remote add origin https://github.com/yangshangwei/commonUtils.gitMr.Yang@Mr MINGW64 /d/workspace/ws-java-base/commonUtils (master) $ git remote -v origin https://github.com/yangshangwei/commonUtils.git (fetch) origin https://github.com/yangshangwei/commonUtils.git (push)Mr.Yang@Mr MINGW64 /d/workspace/ws-java-base/commonUtils (master) $ git push -u origin master Counting objects: 44, done. Delta compression using up to 4 threads. Compressing objects: 100% (28/28), done. Writing objects: 100% (44/44), 10.15 KiB | 0 bytes/s, done. Total 44 (delta 0), reused 0 (delta 0) To https://github.com/yangshangwei/commonUtils.git* [new branch] master -> master Branch master set up to track remote branch master from origin.Mr.Yang@Mr MINGW64 /d/workspace/ws-java-base/commonUtils (master) $

總結(jié)

以上是生活随笔為你收集整理的Git-将已有的项目转换为GIT项目托管到 GITHUB 仓库的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。