目录

​​一、配置用户信息​​

​​避免每次重复输入账号密码​​

​​方法一:​​

​​方法二:​​

​​二、编码配置​​

​​三、本地上传项目到git​​

​​四、Gitee下载项目到本地​​

​​五、删除文件​​


 

 

打开这个客户端

【使用说明】Git基础操作 / 克隆 / 新增 / 更新 / 删除 / 冲突 / 等_用户名

 

 

一、配置用户信息

git config --global user.name "用户名"

配置邮箱(其中邮箱替换成自己的邮箱)
git config --global user.email XXX@163.com

 

避免每次重复输入账号密码

方法一:

安装好git之后一般会在C盘的C:\Users\Administator目录下生成 .gitconfig配置文件(记住,是文件,不是文件夹)。用文档编辑工具打开该文件

添加:

[user]
name = qq123//你的用户名
email = qq123@163.com //你的git邮箱账号
[credential]
helper = store

然后保存就可以了。

方法二:

打开工作空间,右键,选择 git bash ,在打开的窗口中执行命令:
git config --global credential.helper store
去重新下载,第一次输入帐号密码,之后再下载就不会出现了
 

 

 

 


二、编码配置

编码配置,避免git gui中显示中文乱码:
git config --global gui.encoding utf-8

避免git status显示中文文件名乱码:
git config --global core.quotepath off

配置git对文件大小写敏感:
git config --global core.ignorecase false

 

输入命令:git config --list可以查看到设置的全局配置信息。


三、本地上传项目到git

在本地项目目录创建本地仓库 并初始化

git init

上传所有代码到本地仓库(注意add后面有个点,与add之间有一空格)

git add .

这样就把代码上传到本地仓库了

git commit -m "初始化"

在gitee上新建项目,复制https://gitee.com/XXX/XXX.git地址

关联本地仓库并上传代码

git remote add origin https://github.com/XXX/XXX.git

提交到Gitee  (会提示输入Gitee的账号密码)

git push origin master

四、Gitee下载项目到本地

git clone https://gitee.com/XXX/XXX.git

 


 

五、删除文件

1.本地删除

2.上传代码到本地缓存区

git add .

3.

git commit -m '删除aaa.txt'

4.

git push origin master

 


六、更新文件

git pull
git pull --rebase origin master

冲突信息  需要更新

To https://gitee.com/alibbbb/files.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/alibbbb/files.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
 

 


 

七、文件冲突

新push的与之前的版本有冲突,提示推送被挡回,可以强制推送去解决,之前的代码会被覆盖:

​git push -u origin master -f​​ 这里的f 是force强制的意思。

 或者 

编辑冲突内容

git rebase --continue
有冲突继续解决,重复这这些步骤,直到rebase完成。
如果中间遇到某个补丁不需要应用,可以用下面命令忽略
git rebase --skip
如果想回到rebase执行之前的状态,可以执行:
git rebase --abort

 

或者

利用图形界面工具解决冲突

执行git mergetool用预先配置的Beyond Compare解决冲突:

【使用说明】Git基础操作 / 克隆 / 新增 / 更新 / 删除 / 冲突 / 等_上传_02

错误信息

$ git commit -m '修改bbb.txt'
error: Committing is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.

 

 

 


 

 

下载项目到本地

git clone https://gitee.com/用户名/files.git

 

使用 git add 添加本地修改过或者增加的文件。eg: git add test.txt

 

每次提交更新之前最好使用命令git pull将远程代码更新下来,如果有冲突,需要将冲突修改后再通过上面的方式提交

 

 

使用 git status 命令查看当前项目修改情况。

 

 

 

问题

 

1  需要配置用户信息

*** 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 'gw@DESKTOP-9C07DF3.(none)')