闪电龟龟--笔记

万物寻其根,通其堵,便能解其困。
  博客园  :: 新随笔  :: 管理

关于Git的使用

Posted on 2019-11-01 19:26  闪电龟龟  阅读(117)  评论(0编辑  收藏  举报

Git克隆代码:

1建立好相应的文件夹,在对应的文件夹下进行打开Git

 

 

 

克隆项目

git clone -b master https://gitee.com/null_***/***.git

上传代码一共三个代码

第一步:添加/修改的文件(使用点会执行全部文件):git add .

第二步:提交上传注释: git commit  -m "提交说明"

第三步:同步 git push  origin master

 

AddBy 2024-01-09

查看提交记录: git log --oneline

查看最近一次提交修改内容:git show
查看指定提交修改内容:git show  id 注:这里的id可以是下面两种情况

'

 EndBy 2024-01-09

 

AddBy 2024-04-08

本地仓库上传git服务器

详情请参照(仅作笔记记录):远程仓库 | Java学习&面试指南-程序员大彬 (topjavaer.cn)

git init # 将目录变成本地仓库
git add .
git commit -m 'xxx' # 提交到本地仓库
git remote add origin https://github.com/Tyson0314/profile # 关联远程仓库
git branch --set-upstream-to=origin/master master  # 本地分支关联远程分支
git pull origin master --allow-unrelated-histories # 允许合并不相关的历史
git push -u origin master  # 如果当前分支与多个主机存在追踪关系,则-u会指定一个默认主机,这样后面就可以不加任何参数使用git push。

 

EndBy 2024-04-08 

 

 

常遇到的问题一:

如果向远程提交信息失败(fatal: Authentication failed for ...),表明用户认证失败,解决方法如下

1.进行清除原有信息

 

 2.再次进行提交即可看到登录身份信息(账号为登录邮箱。密码为登录密码)

 

AddBy 2023-12-11 

常遇到的问题二:

遇到“error: bad signature 0x00000000” ,是因为在提交过程中存在重启问题导致的

解决办法:(详情请前往Git出错,提示error: bad signature 0x00000000 fatal: index file corrupt(win10系统)_由于错误,无法检查工作树中是否有未合并的文件。-CSDN博客 查看)

rm .git/index -- 有的机器是: rm -f .git/index
git reset

 EndBy 2023-12-11

 

 

Addby 2020-08-11

拉取远程代码(直接合并):git pull origin master

拉取远程代码(不会直接合并):git fetch  origin master

使用git fetch  origin master直至合并流程:

将远程代码先放置于Temp分支:git fetch  origin master:Temp

查看temp分支与本地原有分支的不同:git diff temp

temp分支和本地的master分支合并:git merge temp

Endby 2020-08-11

 

 

Addby 2023-04-10

配置DiffMerge

git配置DiffMerge(建议跳转原文查看/解释更清晰,下面仅仅当做笔记记录)

1、下载DiffMerge

2、创建启动DiffMerge脚本

  在Git的安装路径的\cmd路径下创建以下两个脚本

 

  git-difftool-diffmerge-wrapper.sh内容为:

 # place this file in the Windows Git installation directory /cmd folder
 # be sure to add the ../cmd folder to the Path environment variable
 
 #  parameters:
 # path old-file old-hex old-mode new-file new-hex new-mode
 
 "C:\Program Files\SourceGear\Common\DiffMerge\sgdm.exe" "$1" "$2" | cat

  git-mergetool-diffmerge-wrapper.sh内容为:

# place this file in the Windows Git installation directory /cmd folder
 # be sure to add the ../cmd folder to the Path environment variable
 
 # passing the following parameters to mergetool:
 # local base remote merge_result
 
 "C:\Program Files\SourceGear\Common\DiffMerge\sgdm.exe""$1""$2""$3" --result="$4" --title1="Mine" --title2="Merge" --title3="Theirs"

3、将\cmd设置环境变量,方便找

   将git程序的cmd目录加入环境变量Path

4、修改Git配置(.gitconfig文件,如果是普通用户电脑/管理员不是Administrator名称,一般不在Administrator,在对应的用户名称目录)

 

 修改内容:

[merge]
     tool = diffmerge
 [diff]
     tool = diffmerge
 [mergetool]
     keepBackup = false
 [mergetool "diffmerge"]
     cmd = git-mergetool-diffmerge-wrapper.sh "$LOCAL" "$BASE" "$REMOTE" "$MERGED"
 [difftool "diffmerge"]
     cmd = git-difftool-diffmerge-wrapper.sh "$LOCAL" "$REMOTE"

 

# 提交时查看差异修改了什么
git difftool
# 合并时冲突修改
git mergetool

EndBy