// 创建用户
dyw@sw MINGW64 ~/Desktop
$ git config -- global user.name 'xiaohua'
fatal: not in a git directory
//解决办法
dyw@sw MINGW64 ~/Desktop
$ git init
Initialized empty Git repository in C:/Users/dyw/Desktop/.git/
//设置用户
dyw@swMINGW64 ~/Desktop/test1 (master)
$ git config --global user.email "12345656@qq.com"
//设置用户邮箱
dyw@swMINGW64 ~/Desktop/test1 (master)
$ git config --global user.name "xiaohua"
//创建文件夹
dyw@sw MINGW64 ~/Desktop (master)
$ mkdir test1
//进入新创建文件夹
dyw@sw MINGW64 ~/Desktop (master)
$ cd test1
//初始化
dyw@sw MINGW64 ~/Desktop/test1 (master)
$ git init
Initialized empty Git repository in C:/Users/dyw/Desktop/test1/.git/
//用打开编辑器新建index.html文件
dyw@sw MINGW64 ~/Desktop/test1 (master)
$ touch 'index.html'
//文件通过$ git add '文件名'添加到暂存区,
dyw@sw MINGW64 ~/Desktop/test1 (master)
$ git add 'index.html'
//提交操作
dyw@sw MINGW64 ~/Desktop/test1 (master)
$ git commit -m '创建index.html'
//出现这种问题
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
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 'dyw@ssztdyw.(none)')
//解决方案,从新设置用户
dyw@sw MINGW64 ~/Desktop/test1 (master)
$ git config --global user.email "12345656@qq.com"
dyw@sw MINGW64 ~/Desktop/test1 (master)
$ git config --global user.name "xiaohua"
//git提交操作
dyw@sw MINGW64 ~/Desktop/test1 (master)
$ git commit -m '创建index.html'
[master (root-commit) 66c78fc] 鍒涘缓index.html
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 index.html
//git修改操作
dyw@sw MINGW64 ~/Desktop/test1 (master)
$ git commit -m '修改index.html'
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: index.html
no changes added to commit (use "git add" and/or "git commit -a")
//git删除操作
dyw@sw MINGW64 ~/Desktop/test1 (master)
$ git rm -f index.html
rm 'index.html'
dyw@sw MINGW64 ~/Desktop/test1 (master)
$ git commit -m '删除了index.html'
[master 264098a] 鍒犻櫎浜唅ndex.html
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 index.html
Git初始化及仓库创建和操作,以及问题,解决方案
最新推荐文章于 2022-12-30 14:32:04 发布