git快捷键、问题、注意事项

 

git使用+配置

 

1     配置

 

 

2     使用

 

2.1    git 常用命令以及提交步骤

 

https://blog.csdn.net/qq_29897369/article/details/81430380?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.no_search_link&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.no_search_link

 

2.2    git常用命令

 

https://www.cnblogs.com/miracle77hp/articles/11163532.html

 

https://blog.csdn.net/u013210620/article/details/50318225

 

 

https://blog.csdn.net/u013210620/article/details/50318225

 

2.3    git 硬回滚

 

git log 日志,在回滚的commitId 之后的日志,

不保存

 

2.3.1 命令行操作

 

https://www.cnblogs.com/hukuangjie/p/11369434.html

 

回退命令:

$ git reset --hard HEAD^ 回退到上个版本
$ git reset --hard HEAD~3 回退到前3次提交之前,以此类推,回退到n次提交之前
$ git reset --hard commit_id 退到/进到 指定commit的sha码

强推到远程:

$ git push origin HEAD --force

 

2.4    git 软回滚

 

git log 日志,在回滚的commitId 之后的日志,

保存

 

2.5    git fetch

 

https://blog.csdn.net/weixin_42397269/article/details/105145041

 

2.6    命令行操作

 

https://www.cnblogs.com/smiler/p/6924583.html

 

2.6.1 查看远程分支

 

 

 

2.6.2 查看本地分支

 

 

 

2.6.3 新建分支

 

 

git checkout -b ‘xxx’

 

xxx 新的分支

 

 

2.6.3.1   新建分支并且切换到新的分支

 

 

 

2.6.4 切换分支

 

 

 

2.6.5 退出当前命令状态,q

 

 

 

2.6.6 合并分支代码 到 指定分支

 

 

2.6.7  提交代码

 

git commit -m ‘注释’

 

 

 ?提交代码 并且push 到远程remote

 

 

2.6.8 推送代码到远程

 

git pull

 

 

 

$ git pull

There is no tracking information for the current branch.

Please specify which branch you want to merge with.

See git-pull(1) for details.

 

    git pull <remote> <branch>

 

If you wish to set tracking information for this branch you can do so with:

 

    git branch --set-upstream-to=origin/<branch> develop_you

 

 

2.6.8.1  There is no tracking information for the current branch.

 

Please specify which branch you want to merge with.

 

1、是因为本地分支和远程分支没有建立联系 (使用git branch -vv 可以查看本地分支和远程分支的关联关系) .根据命令行提示只需要执行以下命令即可

(1)     https://www.cnblogs.com/zyjzz/p/7653378.html

①      git branch --set-upstream-to=origin/远程分支的名字  本地分支的名字

1)       git branch –set-upstream-to=origin/new new

2、git branch –set–upstream new origin/new

(1)     (new为新建分支名)

(2)     这样在我们每次想push或者pull的时候,只需要 输入git push 或者git pull即可

 

参考 :

git branch --set-upstream-to=origin/远程分支的名字  本地分支的名字

 

解决:

git branch --set-upstream-to=origin/develop  develop_you

 

 

 

 

3     问题

 

 

3.1    git pull失败

 

youyonga@LXAJT101055101 MINGW64 /d/projects/gits/heatpump-ecological-operation-backend (develop)

$ git branch --set-upstream-to=origin/<branch> develop

bash: branch: No such file or directory

 

 

 

 

 

 

 

3.2    git 忽略指定文件

 

https://www.cnblogs.com/mafeng/p/7635228.html

 

命令行操作

1、 git status

a)       查看变动的文件

b)     

2、  命令行

a)       忽略指定文件

                   i.           git update-index --assume-unchanged heatpump-ecological-operation-backend.log

b)      执行后,再次git status 查看,执行结果

3、  

 

 

3.2.1  ?忽略指定目录文件夹

 

 

 

3.3     \\删除git  log 日志

 

https://zhuanlan.zhihu.com/p/73029640

 

3.4     \\从仓库A下载代码,提交到仓库B

 

GIT-从A仓库迁移至B仓库

 

https://www.cnblogs.com/oumi/p/13968732.html

 

1.检查远程仓库地址

 

   git remote -v

 

2.删除现有远程仓库地址

 

   git remote rm origin

 

3.关联新的仓库地址

 

   git remote add origin ssh//git@新地址

 

4.检查管理结果

 

    git remote -v

 

5.新建本地分支

 

    git checkout -b migrate-init

 

6.检查本地分支

 

    git branch

 

7.关联远程仓库

 

    git push --set-upstream origin migrate-init

 

8.推送代码

 

    git push

 

 

3.5    \\error open filename too long

 

 

 

解决:

在git bash中,运行下列命令: git config --global core.longpaths true

 

3.6     \\ git 配置 ssh key

 

 

https://www.jianshu.com/p/94b39f278214

 

3.7     ? git clone失败,没有权限

 

remote: HTTP Basic: Access denied

fatal: Authentication failed

 

 

3.7.1 重新设置本地的 账号、密码

 

 

 

 

3.7.2  \\git修改账号密码

 

 

https://www.cnblogs.com/dzcici/p/14266321.html

 

 

3.8     ? git config –global –list 查看配置的 用户信息

 

git config –global –list

 

 

 

 

 

3.9     ? remote: HTTP Basic: Access denied

 

https://www.cnblogs.com/xwzblog/p/12589253.html

 

 

 

 

 

3.10 ?设置一个只有自己有权限的git分支

 

 

 

3.11 git push 失败

 

 

3.11.1           \\?fatal: The upstream branch of your current branch does not match

 

 

$ git push

fatal: The upstream branch of your current branch does not match

the name of your current branch.  To push to the upstream branch

on the remote, use

    git push origin HEAD:develop

To push to the branch of the same name on the remote, use

    git push origin HEAD

To choose either option permanently, see push.default in 'git help config'.

 

 

 

 

 

3.11.1.1       解决

 

git branch --set-upstream-to=origin/develop_you  develop_you

 

3.12  ?本地分支和远程分支建立关系

 

 

3.13  ?查看本地分支和远程分支的关联关系

 

git branch -vv

 

 

 

3.14  ?git新建分支并且在切换分支开发

 

https://www.cnblogs.com/fengnovo/p/9428463.html

 

 

 

 

3.15  ?git pull error

 

 

 

 

 

 

 

3.16  ?git merge xxx(指定分支) 报错

 

 

 

 

Unmerged paths:

  (use "git add <file>..." to mark resolution)

        both modified:   idomsd-spm-starter/src/main/resources/logback.xml

 

 

3.17 \\git merge dev出现冲突

 

1、 before

a)      

2、 deal

a)       参考资料

                   i.           https://www.cnblogs.com/aidixie/p/12577272.html

b)      查看冲突文件

c)      

                   i.           冲突代码

d)      解决冲突后提交

                   i.           git add .

                  ii.           git commit –m ‘xxx’

                 iii.           git push

3、 after

a)       git merge dev

                   i.          

 

3.18 \\删除分支,本地、远程

 

https://www.cnblogs.com/liyong888/p/9822410.html

 

 

 

先切换到其他分支,

git checkout xxx

 

删除本地分支

git branch –d xxx

 

强制删除本地分支

git branch –D xxx

 

删除远程分支

git push origin --delete xxx

 

3.18.1          不能删除 当前所在分支

 

只能删除 非当前分支

 

3.19 新建分支,推到远程

 

https://www.cnblogs.com/smileyes/p/8943234.html

 

1) 切换到基础分支,如主干

       git checkout master

2)创建并切换到新分支

       git checkout -b panda

       git branch可以看到已经在panda分支上

3)更新分支代码并提交

       git add *

       git commit -m "init panda"

       git push origin panda

4)在git代码管理界面经可以看到panda分支了,成功~~

 

https://www.cnblogs.com/smileyes/p/8943234.html

 

本地新建分支,

将本地分支代码 push 到远程

 

解决前,报错

 

 

git push --set-upstream origin youyong-dev

 

 

 

解决后

 

 

3.19.1          解决 git pull 无源问题

 

1、 解决前

a)      

2、 解决中

a)       git branch --set-upstream-to=origin youyong-dev-2

b)     

3、 解决后

a)      

 

3.19.2          解决git push 无源问题

 

用 git push origin youyong-dev

解决

 

或者

设置push 源

git push –set-upstream origin youyong-dev

解决

 

解决前

解决中

 

解决后

 

 

3.19.3          git push 无源问题

 

1、 解决前

a)      

2、 解决中

a)      

3、 解决后

a)      

 

3.20 强制将本地代码 Push 到远程

 

https://blog.csdn.net/weixin_43290229/article/details/86410263

 

 

 

3.21  \\git最新代码同步到指定分支(git merge dev 合并指定分支代码)

 

https://blog.csdn.net/m0_37679452/article/details/115241673

 

3.21.1           ?git命令行操作

 

3.21.2          idea操作

 

 

 

3.22  git代码回滚到指定版本

 

https://www.cnblogs.com/yeujuan/p/11971385.html

 

【git】Git回退代码到指定版本

1. 查看所有的历史版本,获取你git的某个历史版本的id, git log

2. 回退本地代码库:git reset --hard ID

3. 推送到远程服务器:git push -f -u origin master

4. 重新拉代码:git pull

 

4     xx

 

posted @   游泳123456789  阅读(200)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
点击右上角即可分享
微信分享提示