GIT 提交项目

2019-10-01  本文已影响0人  小迷糊紫靈

一、初始化项目

在项目中初始化git仓库

git init

初始化后会自动创建.git的文件夹,.git文件夹为本地仓库。

$ git init
Initialized empty Git repository in 项目路径/.git/

到此已经初git本地仓库已经创建成功。

二、关联远程仓库

git remote add origin 项目地址

三、提交文件到本地仓库

git add .

提交时会显示所需要提交的文件

$ git add .
warning: LF will be replaced by CRLF in .idea/workspace.xml.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in my-utils/pom.xml.
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

后面的“.”标识当前目录的所有文件提交。

四、创建提交备注信息

git commit -m “备注信息”
$ git commit -m '初始化提交'
[master (root-commit) fc03ad2] 初始化提交
 9 files changed, 168 insertions(+)
 create mode 100644 .idea/compiler.xml
 create mode 100644 .idea/misc.xml
 create mode 100644 .idea/workspace.xml
 create mode 100644 my-tools.iml
 create mode 100644 my-utils/my-util-exception/pom.xml
 create mode 100644 my-utils/my-util-exception/src/main/java/pers/yiming/App.java
 create mode 100644 my-utils/my-util-exception/src/test/java/pers/yiming/AppTest.java
 create mode 100644 my-utils/pom.xml
 create mode 100644 pom.xml

五、强制提交

在提交的时候加上-f会强制提交当前版本到远程仓库

git push -u origin master -f

六、输入电子邮件和名称

git config user.email “email”
git config user.name “username”

六、异常

当已经使用过git的时候,会提示无法提交的情况。

$ git push -u origin master -f
remote: You do not have permission to push to the repository via HTTPS
fatal: Authentication failed for '项目地址'

解决办法:
在控制面板中搜索凭据,找到windows凭据修改对应的账号密码即可。

上一篇 下一篇

猜你喜欢

热点阅读