git上传项目

1.如何使用Git上传项目代码到github
2.Git新手入门与上传项目到远路仓库GitHub
3. github常见操作和常见错误!错误提示:fatal: remote origin already exists.
4.【已解决】github中git push origin master出错:error: failed to push some refs to
5.github上传时出现error: src refspec master does not match any解决办法
基本上按上面几篇文章来操作就可以了。
不过还是记录一下自己的具体步骤:
注意下面的步骤不包括git的配置安装过程,具体的配置安装请参考上述的博客,下面所述只是在安装配置成功后进行上传项目的步骤
1.先进入你要上传项目的根目录下,如F:\myprojects\springmvc Maven Webapp

lenovo@idea-PC MINGW64 ~
$ cd f:

lenovo@idea-PC MINGW64 /f
$ cd myprojects

lenovo@idea-PC MINGW64 /f/myprojects
$ cd springmvc Maven Webapp
bash: cd: springmvc: No such file or directory

lenovo@idea-PC MINGW64 /f/myprojects
$ cd "springmvc Maven Webapp"

2.初始化,创建了一个名为.git的文件夹

lenovo@idea-PC MINGW64 /f/myprojects/springmvc Maven Webapp
$ git init
Initialized empty Git repository in F:/myprojects/springmvc Maven Webapp/.git/

lenovo@idea-PC MINGW64 /f/myprojects/springmvc Maven Webapp (master)

3.git add . (将改动添加到暂存区)

lenovo@idea-PC MINGW64 /f/myprojects/springmvc Maven Webapp (master)
$ git add .
warning: LF will be replaced by CRLF in .mymetadata.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in pom.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in src/main/resources/spring-mybatis.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in src/main/webapp/WEB-INF/web.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in src/main/webapp/index.jsp.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in target/classes/spring-mybatis.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in target/m2e-jee/web-resources/META-INF/maven/org.springmvc/springmvc/pom.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in target/surefire-reports/TEST-net.cxp.test.TestMyBatis.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in target/surefire-reports/net.cxp.test.TestMyBatis.txt.
The file will have its original line endings in your working directory.

4.在你的github账户下新建一个repository ,注意这是在网页上进行,不是在本地进行
5.
千万记得下面说的“你的github用户名”不是你用$ git config –global user.name “your name”这句创建的用户名,而是你github账户上显示的用户名,后面的springmvc也是你在网页上(也就是服务器端)新建的仓库(create a new repository)。

touch README
git add README
git commit -m "first commit"
git remote add origin git@github.com:你的github用户名/springmvc.git
git push -u origin master

下面是具体显示

touch README
git add README
git commit -m "first commit"
[master (root-commit) 74ec194] first commit
 64 files changed, 3030 insertions(+)
 create mode 100644 .classpath
 create mode 100644 .mymetadata
 create mode 100644 .myumldata
 create mode 100644 .project
 create mode 100644 .settings/.jsdtscope
 create mode 100644 .settings/com.genuitec.eclipse.j2eedt.core.prefs
 create mode 100644 .settings/com.genuitec.jboss.ide.eclipse.xdoclet.run.prefs
 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 .settings/org.eclipse.wst.common.component
 create mode 100644 .settings/org.eclipse.wst.common.project.facet.core.xml
 create mode 100644 .settings/org.eclipse.wst.jsdt.ui.superType.container
 create mode 100644 .settings/org.eclipse.wst.jsdt.ui.superType.name
 create mode 100644 README
 create mode 100644 logs/ssm.log
 create mode 100644 pom.xml
 create mode 100644 springmvc.sql
 create mode 100644 src/main/java/net/cxp/controller/GreetingController.java
 create mode 100644 src/main/java/net/cxp/controller/UsersController.java
 create mode 100644 src/main/java/net/cxp/dao/UsersMapper.java
 create mode 100644 src/main/java/net/cxp/mapping/UsersMapper.xml
 create mode 100644 src/main/java/net/cxp/pojo/Users.java
 create mode 100644 src/main/java/net/cxp/service/UsersService.java
 create mode 100644 src/main/java/net/cxp/service/impl/UsersServiceImpl.java
 create mode 100644 src/main/resources/jdbc.properties
 create mode 100644 src/main/resources/log4j.properties
 create mode 100644 src/main/resources/spring-mvc.xml
 create mode 100644 src/main/resources/spring-mybatis.xml
 create mode 100644 src/main/webapp/META-INF/MANIFEST.MF
 create mode 100644 src/main/webapp/WEB-INF/classes/net/cxp/controller/GreetingController.class
 create mode 100644 src/main/webapp/WEB-INF/classes/net/cxp/controller/UsersController.class
 create mode 100644 src/main/webapp/WEB-INF/classes/net/cxp/dao/UsersMapper.class
 create mode 100644 src/main/webapp/WEB-INF/classes/net/cxp/mapping/UsersMapper.xml
 create mode 100644 src/main/webapp/WEB-INF/classes/net/cxp/pojo/Users.class
 create mode 100644 src/main/webapp/WEB-INF/classes/net/cxp/service/UsersService.class
 create mode 100644 src/main/webapp/WEB-INF/classes/net/cxp/service/impl/UsersServiceImpl.class
 create mode 100644 src/main/webapp/WEB-INF/classes/net/cxp/test/TestMyBatis.class
 create mode 100644 src/main/webapp/WEB-INF/web.xml
 create mode 100644 src/main/webapp/greeting.jsp
 create mode 100644 src/main/webapp/index.jsp
 create mode 100644 src/main/webapp/showUser.jsp
 create mode 100644 src/test/java/net/cxp/test/TestMyBatis.java
 create mode 100644 target/classes/jdbc.properties
 create mode 100644 target/classes/log4j.properties
 create mode 100644 target/classes/net/cxp/controller/GreetingController.class
 create mode 100644 target/classes/net/cxp/controller/UsersController.class
 create mode 100644 target/classes/net/cxp/dao/UsersMapper.class
 create mode 100644 target/classes/net/cxp/mapping/UsersMapper.xml
 create mode 100644 target/classes/net/cxp/pojo/Users.class
 create mode 100644 target/classes/net/cxp/service/UsersService.class
 create mode 100644 target/classes/net/cxp/service/impl/UsersServiceImpl.class
 create mode 100644 target/classes/spring-mvc.xml
 create mode 100644 target/classes/spring-mybatis.xml
 create mode 100644 target/m2e-jee/web-resources/META-INF/MANIFEST.MF
 create mode 100644 target/m2e-jee/web-resources/META-INF/maven/org.springmvc/springmvc/pom.properties
 create mode 100644 target/m2e-jee/web-resources/META-INF/maven/org.springmvc/springmvc/pom.xml
 create mode 100644 target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
 create mode 100644 target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
 create mode 100644 target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
 create mode 100644 target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
 create mode 100644 target/surefire-reports/TEST-net.cxp.test.TestMyBatis.xml
 create mode 100644 target/surefire-reports/net.cxp.test.TestMyBatis.txt
 create mode 100644 target/test-classes/net/cxp/test/TestMyBatis.class

git remote add origin git@github.com:你的用户名/springmvc.git
git push -u origin master

出现

Counting objects: 116, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (78/78), done.
Writing objects: 100% (116/116), 30.65 KiB | 0 bytes/s, done.
Total 116 (delta 9), reused 0 (delta 0)
remote: Resolving deltas: 100% (9/9), done.
To github.com:chenxiaopan/springmvc.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

就说明成功了。

### 通过 Git 上传项目的具体步骤 要将本地项目上传至远程仓库(如 GitLab),可以按照以下方法完成: #### 关联远程仓库 在开始之前,需要先将本地仓库与远程仓库建立连接。可以通过 `git remote add` 命令实现此操作。假设远程仓库地址为 `https://gitlab-lizz.com/lizz/testProject.git`,则执行如下命令: ```bash git remote add origin https://gitlab-lizz.com/lizz/testProject.git ``` 这一步用于指定远程仓库的位置[^2]。 #### 添加文件到暂存区 为了准备提交,需将所有更改的文件添加到暂存区。使用以下命令即可一次性添加当前目录下的全部文件: ```bash git add . ``` #### 提交更改到本地仓库 接着,利用 `commit` 将暂存区的内容正式记录下来,并附带一条描述性的消息以便后续查阅版本历史信息: ```bash git commit -m "初始化项目或者更新内容" ``` 这里的消息可以根据实际需求调整,比如初次创建时写成“初始化项目”,而后期维护阶段可能改为更具体的改动说明[^1]。 #### 推送数据到远程服务器 最后一步就是把已经存在于本地repo中的东西同步给远端server了。如果是第一次推送,则还需要额外加上 `-u` 参数来设置默认分支跟踪关系;如果不是首次推送的话可以直接运行简单的push语句就行啦~ 对于新库来说一般会这样子做: ```bash git push -u origin master ``` 如果目标平台采用的是 main 而不是传统的master作为初始branch名称,那么就应该相应修改上述指令里的那个单词部分咯~比如说变成main而不是master那样哈~ 以上便是完整的流程介绍[^3]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值