Git-将已有的项目转换为GIT项目托管到 GITHUB 仓库
来源:互联网 发布:淘宝760的lamy2000 编辑:程序博客网 时间:2024/05/22 01:32
- 概述
- 步骤
- GIT软件安装
- 初始化本地maven项目为 Git 项目
- 将所有文件放进新的本地 git 仓库
- 将添加的文件提交到仓库
- GitHub上创建项目 copy项目地址
- 回到命令行终端界面将本地仓库关联到远程仓库
- 提交代码到 GitHub 仓库
- Github上查看项目
- Github提示信息
- 在Spring Tool Suite中连接GITHUB
- 另外一个Java项目托管到github上的完整操作
概述
打算将SpringMaster项目托管到GitHub,方便查阅
最终效果如下:
步骤
1.GIT软件安装
现在并安装GIT
我们这里使用通过命令行的方式将本地项目托管到GITHUB。
2.初始化本地maven项目为 Git 项目
本地项目目录: D:\workspace\workspace-sts\SpringMaster
打开GIT BASH,进入到项目所在目录
执行命令
$ git init
此时会在目录中创建一个 .git 隐藏文件夹,如下
3.将所有文件放进新的本地 git 仓库
$ git add .
如果你本地已经有 .gitignore
文件,会按照已有规则过滤不需要添加的文件。如果不想要添加所有文件,可以把 .
符号换成具体的文件名
4. 将添加的文件提交到仓库
git commit -m "Initial commit"
5. GitHub上创建项目 ,copy项目地址
创建过程省略,最后如下所示:
https://github.com/yangshangwei/SpringMaster.git 复制仓库地址
6. 回到命令行终端界面,将本地仓库关联到远程仓库
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 -vorigin https://github.com/yangshangwei/SpringMaster.git (fetch)origin https://github.com/yangshangwei/SpringMaster.git (push)
通过 git remote -v
命令查看结果
7. 提交代码到 GitHub 仓库
Mr.Yang@Mr MINGW64 /d/workspace/workspace-sts/SpringMaster (master)$ git push -u origin masterCounting 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 -> masterBranch master set up to track remote branch master from origin.
8. Github上查看项目
Github提示信息
仓库创建成功后,Github如下提示信息,可以指导我们将项目托管到GITHUB 仓库
…or create a new repository on the command lineecho "# SpringMaster" >> README.mdgit initgit add README.mdgit commit -m "first commit"git remote add origin https://github.com/yangshangwei/SpringMaster.gitgit push -u origin master…or push an existing repository from the command linegit remote add origin https://github.com/yangshangwei/SpringMaster.gitgit push -u origin master…or import code from another repositoryYou 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 initInitialized 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 commit 18 files changed, 438 insertions(+) create mode 100644 .classpath create mode 100644 .project create mode 100644 .settings/org.eclipse.core.resources.prefs create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 .settings/org.eclipse.m2e.core.prefs create mode 100644 pom.xml create mode 100644 src/main/java/com/artisan/commonUtils/App.java create mode 100644 src/main/java/com/artisan/commonUtils/getPath/PathUtil.java create mode 100644 src/main/java/com/artisan/commonUtils/getPath/PathUtilDemo.java create mode 100644 src/main/java/com/artisan/commonUtils/mail/MailServer.properties create mode 100644 src/main/java/com/artisan/commonUtils/mail/SendEmailUtil.java create mode 100644 src/test/java/com/artisan/commonUtils/AppTest.java create mode 100644 target/classes/com/artisan/commonUtils/App.class create mode 100644 target/classes/com/artisan/commonUtils/getPath/PathUtil.class create mode 100644 target/classes/com/artisan/commonUtils/getPath/PathUtilDemo.class create mode 100644 target/classes/com/artisan/commonUtils/mail/MailServer.properties create mode 100644 target/classes/com/artisan/commonUtils/mail/SendEmailUtil.class create 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 -vorigin 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 masterCounting 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 -> masterBranch master set up to track remote branch master from origin.Mr.Yang@Mr MINGW64 /d/workspace/ws-java-base/commonUtils (master)$
阅读全文
1 0
- Git-将已有的项目转换为GIT项目托管到 GITHUB 仓库
- 如何将一个已存在的目录转换为一个 GIT 项目并托管到 GITHUB 仓库
- 如何将一个已存在的目录转换为一个 GIT 项目并托管到 GITHUB 仓库
- 如何将一个已存在的目录转换为一个 GIT 项目并托管到 GITHUB 仓库
- Git--将已有的项目添加到github
- Git--将已有的项目添加到github
- 将已有的项目添加到git
- Git-将已有的项目提交到Git
- git 上传已有的本地项目到github
- 将已有的项目添加到github
- 如何将项目同时托管到 Git@OSC 和 Github
- 如何将项目同时托管到 Git@OSC 和 GitHub
- 将项目同时托管到Github和Git@OSC
- 如何将一个已有的项目托管到github或是码云上?
- 如何通过git将项目推送到github远程仓库
- github如何将已有的项目转移到组织仓库中去
- Git上传项目到远路仓库GitHub
- 添加已有的git项目
- mysql连数据库时出问题
- 拷贝文件的时候显示进度
- 修改nginx 和 apache的最大上传文件大小
- jsonp详解
- 说说过去,现状与未来定位
- Git-将已有的项目转换为GIT项目托管到 GITHUB 仓库
- 并查集
- springboot maven指定jar包的选择
- ubuntu17.04 使用 steam 玩游戏时字体无显示解决办法
- 图片间有空隙的解决方法
- HDU5806 NanoApe Loves Sequence Ⅱ【尺取法+乘法原理】
- PX4代码学习系列博客(2)——PX4与实时操作系统
- 逻辑运算符 或 与 非 位运算
- 滚动数组