• git备忘(长久更新)


          一直想了解一下git,正好最近的有一个问题就是,实验室写的代码,怎么同步到自己宿舍的笔记本上面来。最开始想用dropbox,但是用VS的人都知道,工程文件里面会给你生成乱七八糟的很多东西,很占空间,dropbox好像没有选择同步某个文件的功能,只能同步某个文件夹。以前看过git,但是好久没用,隔了一俩个月就忘了。这里把常用的概念、命令做个笔记。

      资料大部分来源于这里

        1.文件的三种状态:已提交(committed),已修改(modified)和已暂存(staged)。已提交表示该文件已经被安全地保存在本地数据库中了;已修改表示修改了某个文件,但还没有提交保存;已暂存表示把已修改的文件放在下次提交时要保存的清单中。

      2. git  config --global user.name

        git  config --global user.email       --//设置账号

          git  config --list                          --//查看配置列表

          git  clone [url]                            --//获取仓库

          git  status                        --//检查当前文件文件状态

              git  add                                     --//1)添加某个文件 2)将文件从已修改的状态变到已暂存的状态

                                              --//在整个工程文件夹下,git init 了之后,设置好.gitignore规则之后输入命令 git add .  就可以添加所有的工程文件。

        git  commit -m "init first project"    --//这个是提交,从已暂存的状态转变到已提交的状态  -m 参数 后面跟此次提交的说明

          git  commit -a                              --//此命令跳过git add过程,即跳过已暂存的状态 直接从已修改--》已提交

        git  remote -v                              --//显示远程仓库的名字和位置

          git  remote add [shortname] [url]  --//添加远程仓库

          git  remote rename a b                 --//将仓库名字a改为b

          git  push -u origin master             --//将本地的分支push到远程仓库里面

          git  rm [filename]                         --//删除文件

      3.  .gitignore 在这个文件里面,git会根据文件里面的规则忽略指定文件。下面是一个从网上淘来的VS工程的模版

      1 ## Ignore Visual Studio temporary files, build results, and
      2 ## files generated by popular Visual Studio add-ons.
      3 
      4 # User-specific files
      5 *.suo
      6 *.user
      7 *.sln.docstates
      8 
      9 # Build results
     10 [Dd]ebug/
     11 [Dd]ebugPublic/
     12 [Rr]elease/
     13 x64/
     14 build/
     15 bld/
     16 [Bb]in/
     17 [Oo]bj/
     18 
     19 # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
     20 !packages/*/build/
     21 
     22 # MSTest test Results
     23 [Tt]est[Rr]esult*/
     24 [Bb]uild[Ll]og.*
     25 
     26 #NUNIT
     27 *.VisualState.xml
     28 TestResult.xml
     29 
     30 *_i.c
     31 *_p.c
     32 *_i.h
     33 *.ilk
     34 *.meta
     35 *.obj
     36 *.pch
     37 *.pdb
     38 *.pgc
     39 *.pgd
     40 *.rsp
     41 *.sbr
     42 *.tlb
     43 *.tli
     44 *.tlh
     45 *.tmp
     46 *.tmp_proj
     47 *.log
     48 *.vspscc
     49 *.vssscc
     50 .builds
     51 *.pidb
     52 *.svclog
     53 *.scc
     54 
     55 # Chutzpah Test files
     56 _Chutzpah*
     57 
     58 # Visual C++ cache files
     59 ipch/
     60 *.aps
     61 *.ncb
     62 *.opensdf
     63 *.sdf
     64 *.cachefile
     65 
     66 # Visual Studio profiler
     67 *.psess
     68 *.vsp
     69 *.vspx
     70 
     71 # TFS 2012 Local Workspace
     72 $tf/
     73 
     74 # Guidance Automation Toolkit
     75 *.gpState
     76 
     77 # ReSharper is a .NET coding add-in
     78 _ReSharper*/
     79 *.[Rr]e[Ss]harper
     80 *.DotSettings.user
     81 
     82 # JustCode is a .NET coding addin-in
     83 .JustCode
     84 
     85 # TeamCity is a build add-in
     86 _TeamCity*
     87 
     88 # DotCover is a Code Coverage Tool
     89 *.dotCover
     90 
     91 # NCrunch
     92 *.ncrunch*
     93 _NCrunch_*
     94 .*crunch*.local.xml
     95 
     96 # MightyMoose
     97 *.mm.*
     98 AutoTest.Net/
     99 
    100 # Installshield output folder
    101 [Ee]xpress/
    102 
    103 # DocProject is a documentation generator add-in
    104 DocProject/buildhelp/
    105 DocProject/Help/*.HxT
    106 DocProject/Help/*.HxC
    107 DocProject/Help/*.hhc
    108 DocProject/Help/*.hhk
    109 DocProject/Help/*.hhp
    110 DocProject/Help/Html2
    111 DocProject/Help/html
    112 
    113 # Click-Once directory
    114 publish/
    115 
    116 # Publish Web Output
    117 *.Publish.xml
    118 *.azurePubxml
    119 
    120 # NuGet Packages Directory
    121 ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
    122 #packages/
    123 ## TODO: If the tool you use requires repositories.config, also uncomment the next line
    124 #!packages/repositories.config
    125 
    126 # Windows Azure Build Output
    127 csx/
    128 *.build.csdef
    129 
    130 # Windows Store app package directory
    131 AppPackages/
    132 
    133 # Others
    134 sql/
    135 *.Cache
    136 ClientBin/
    137 [Ss]tyle[Cc]op.*
    138 ~$*
    139 *~
    140 *.dbmdl
    141 *.dbproj.schemaview
    142 *.[Pp]ublish.xml
    143 *.pfx
    144 *.publishsettings
    145 
    146 # RIA/Silverlight projects
    147 Generated_Code/
    148 
    149 # Backup & report files from converting an old project file to a newer
    150 # Visual Studio version. Backup files are not needed, because we have git ;-)
    151 _UpgradeReport_Files/
    152 Backup*/
    153 UpgradeLog*.XML
    154 UpgradeLog*.htm
    155 
    156 # SQL Server files
    157 App_Data/*.mdf
    158 App_Data/*.ldf
    159 
    160 # Business Intelligence projects
    161 *.rdl.data
    162 *.bim.layout
    163 *.bim_*.settings
    164 
    165 # Microsoft Fakes
    166 FakesAssemblies/
    167 
    168 # =========================
    169 # Windows detritus
    170 # =========================
    171 
    172 # Windows image file caches
    173 Thumbs.db
    174 ehthumbs.db
    175 
    176 # Folder config file
    177 Desktop.ini
    178 
    179 # Recycle Bin used on file shares
    180 $RECYCLE.BIN/
    View Code

         

  • 相关阅读:
    springboot2整合seata(AT模式)
    SpringBoot2整合minio
    Minio安装(docker)、初始密码及界面操作
    elasticsearch mapper创建
    elasticsearch 中文分词
    C++11:20weak_ptr弱引用的智能指针
    C++11:19unique_ptr独占的智能指针
    C++11:18shared_ptr共享的智能指针
    C++11:17可变参数模版和type_traits的综合应用
    C++11:16可变参数模板
  • 原文地址:https://www.cnblogs.com/xibaohe/p/3466680.html
Copyright © 2020-2023  润新知