zoukankan      html  css  js  c++  java
  • GIt 错误与常用命令

    命令和一些其他的属性等

    *)在使用git commit -m “description" 这个描述会加在上次提交后所有add的文件后面,所以也可能产生不符合这个描述的文件后面也跟了这个描述,所以建议若是有多个不能用 一个描述概括 的不同的文件,就分成两次提交

      就是因为.gitignore 和merge_sort.py一块提交了

    *)不再跟踪文件

      参考链接:https://blog.csdn.net/qinglianluan/article/details/50436822

    git rm filename --cached #在磁盘中保留文件
    git rm filename -f #磁盘上的文件也会删除

      

    *)查看暂存区中文件,及文件内容

      参考链接:https://www.jianshu.com/p/abca119649b5

      文件内容的方法见参考链接

    git ls-files
    
    #参数介绍(跟在上面命令的后面) 
    --cached(-c)显示暂存区中的文件,git ls-files命令默认的参数
    --deleted(-d)显示删除的文件
    --modified(-m)    显示修改过的文件
    --other(-o)显示没有被git跟踪的文件
    --stage(-s) 显示mode以及文件对应的Blob对象,进而我们可以获取暂存区中对应文件里面的内容。。
    

      

    *)帮助命令

    git --help branch #会在浏览器中打开
    

      

    *)stage 代表暂存区

    *)比较不同

      

    git diff  readme.txt
    git diff HEAD -- readme.txt#命令可以查看工作区和版本库里面最新版本的区别
    

      

    *)提交记录

    git log --graph --pretty=oneline --abbrev-commit #garph:图形;abbrev:缩写
    

      

    *)git后面括号中的(master->gitee)的颜色

    红色代表本地和远程(通过git pull)的有冲突、或者unmerge paths

    浅黄色代表未提交

    *)当某个命令会有多行输出结果时,git 会出现一个“:”号,按Enter会输出下一行,End直接到末尾,Home向上一页,q退出

    diff --cc .gitignore                                                                
    index 20d7888,11614af..0000000                                                      
    --- a/.gitignore                                                                    
    +++ b/.gitignore                                                                    
    @@@ -1,6 -1,115 +1,124 @@@                                                          
    ++<<<<<<< HEAD                                                                      
     +#python                                                                           
     +forTest.py                                                                        
     +Git_bubble_sort_matplotlib.py                                                     
     +Git_data.py                                                                       
     +Git_output_matplotlib.py                                                          
    - __pycache__                                                                       
    ++__pycache__                                                                       
    ++=======                                                                           
    + # Byte-compiled / optimized / DLL files                                           
    + __pycache__/                                                                      
    + *.py[cod]                                                                         
    + *$py.class                                                                        
    +                                                                                   
    + # C extensions                                                                    
    + *.so                                                                              
    +                                                                                   
    + # Distribution / packaging                                                        
    + .Python                                                                           
    + build/                                                                            
    + develop-eggs/                                                                     
    + dist/                                                                             
    + downloads/                                                                        
    + eggs/                                                                             
    + .eggs/                                                                            
    + lib/                                                                              
    + lib64/                                                                            
    + parts/                                                                            
    + sdist/                                                                            
    + var/                                                                              
    + wheels/                                                                           
    + share/python-wheels/                                                              
    + *.egg-info/                                                                       
    + .installed.cfg                                                                    
    + *.egg                                                                             
    + MANIFEST                                                                          
    +                                                                                   
    + # PyInstaller                                                                     
    + #  Usually these files are written by a python script from a template             
    + #  before PyInstaller builds the exe, so as to inject date/other infos into it.   
    + *.manifest                                                                        
    + *.spec                                                                            
    +                                                                                   
    :                                                                                   
    

      

    *)在git status命令时显示的Untracked files ... 代表未使用git add 添加进去,可以在Git工作区的根目录下创建一个特殊的.gitignore文件,然后把要忽略的文件名填进去,Git就会自动忽略这些文件。

    *)(不确定)对远程操作时都要带上origin关键字 不对,origin是默认的远程库的名字

    *)一些解释

    λ git log --graph --pretty=oneline --abbrev-commit
    * 836a213 (HEAD -> master, origin/master, origin/dev2) study cooperation#类似这些提示是所有的提交,包括所有文件的提交,这些提交中有的是对文件A的改动,有些是对文件B的改动,有些是对一批文件的改动
    * 59b2b66 学习bug分支
    * e0d028a 检查是否删除后依然能看出合并过
    *   61f64f3 merge with no-ff
    |
    | * 5c287fe modify this
    |/
    *   127f749 conflict fixed
    |
    | * fb4d959 and simple
    * | 466aa52 & simple
    |/
    * a8a3763 don't konw what
    * b0bb2c9 add new line
    * 389efcb banch test
    * e9db995 add test.txt
    * 22ccc69 git trackes(跟踪器) change
    * 2561b39 理解stage怎么工作的
    * 7acc523 '再次修改readme.txt'
    * c72e38e '添加了单词distributed'
    * 06bcd78 '添加了三个文件'
    * b30fedb 创建了一个readme.txt

    问题

    *)密码失败  remote: Incorrect username or password ( access token )

    remote: Incorrect username or password ( access token )
    fatal: Authentication failed for 'https://gitee.com/gaokingk/Visualization_sort.git/'
    

      解决办法,打开控制面板-》用户账户-》凭据管理器

      参考链接:https://blog.csdn.net/mmyhs/article/details/81589419

    *)git pull 时失败 fetal:refusing to merge unrelate histories:

    参考链接:https://blog.csdn.net/lindexi_gd/article/details/52554159

    Git会检查github 的仓库和本地的没有一个共同的 commit 所以 git 不让提交,认为是写错了 origin ,如果开发者确定是这个 origin 就可以使用 --allow-unrelated-histories 告诉 git 自己确定

    C:UsersAdministrator.SC-202132Envssortapp (master -> gitee) 
    λ git pull                                                             
    fatal: refusing to merge unrelated histories                           
                                                                           
    C:UsersAdministrator.SC-2012Envssortapp (master -> gitee) 
    λ git pull --allow-unrelated-histories                                 
    Auto-merging .gitignore                                                
    CONFLICT (add/add): Merge conflict in .gitignore                       
    Automatic merge failed; fix conflicts and then commit the result.      
    

      

    错误

    *)刚创建本地仓库时如果不添加文件,使用git branch 不显示master分支的

    *)git commit -m后面紧跟的说明中如果时中文或者中英文混合的应该用双引号

    λ git commit -m "git trackes(跟踪器) change"有中文时应该用双引号
    [master 22ccc69] git trackes(跟踪器) change
     1 file changed, 2 insertions(+), 1 deletion(-)
    

      

  • 相关阅读:
    Git常用命令
    C++ 四种强制类型转换
    Linux系统日志及日志分析
    C/C++中的getline函数总结:
    标准C++中的string类的用法总结
    C++中map的基本操作和使用;
    一个C++类的注释:
    C++ 中宏的使用 --来自:http://blog.csdn.net/hgl868/article/details/7058906
    c++ 的vector
    c++强制类型转换:dynamic_cast、const_cast 、static_cast、reinterpret_cast
  • 原文地址:https://www.cnblogs.com/Gaoqiking/p/11112513.html
Copyright © 2011-2022 走看看