本地项目如何上传到git 使用命令行

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_40990836/article/details/83543516

本地项目上传到git中使用命令行

第一步: 先进入到项目文件夹中

$ cd /z/gssznb/*/*

第二步:将项目文件夹初始化

$ git init

第三步:将文件添加到版本库中,不要拉下最后一个 点 ,表示添加所有得文件

git add . 

第四步:使用git commit 提交到仓库 引号中表示为提交说明

git commit -m 'first commit'

第五步: 关联到远程仓库

git remote add origin 你的远程库地址

第六步: 获取远程库与本地同步合并(如果远程库不为空必须做这一步,否则后面的提交会失败)

$ git pull --rebase origin master

第七步: 把本地库的内容推送到远程,使用 git push命令,实际上是把当前分支master推送到远程。执行此命令后会要求输入用户名、密码,验证通过后即开始上传。

git push -u origin master

遇到的问题以及总结

$ git commit -m 'first commit'

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'gssznb@gssznb.(none)')

解决方式:
找到项目工程文件夹中的 .git文件夹。找到之后打开config文件。在最后加上一句话
[user]
email=your email
name=your name
贴上我自己的修改方式

[user]
	email = [email protected]
	name = gssnb
$ git pull --rebase origin master
warning: no common commits
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From https://gitee.com/gssnb/blog
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> origin/master
First, rewinding head to replay your work on top of it...
Applying: first commit

解决方式 :

后来发现原来是 提交到版本库中的文件没有没有提交到 分支中,还在暂存区

所以执行 

git commit -m 'xx' 就行了

猜你喜欢

转载自blog.csdn.net/qq_40990836/article/details/83543516
今日推荐