zoukankan      html  css  js  c++  java
  • git

    1,对于一个新文件,未入版本库的话,git如下提示:

    [luwenwei@appdev115 ~/git/helww/labs/go]$ git status base/channel/test2.go 
    # 位于分支 master
    # 未跟踪的文件:
    #   (使用 "git add <file>..." 以包含要提交的内容)
    #
    #    base/channel/test2.go
    提交为空,但是存在尚未跟踪的文件(使用 "git add" 建立跟踪)

    2,对于新的文件,已经git add操作过的话,文件状态是:

    [luwenwei@appdev115 ~/git/helww/labs/go]$ git status base/channel/test1.go 
    # 位于分支 master
    # 要提交的变更:
    #   (使用 "git reset HEAD <file>..." 撤出暂存区)
    #
    #    新文件:    base/channel/test1.go
    #

    3,git commit提交文件到本地git库

    [luwenwei@appdev115 ~/git/helww/labs/go]$ git commit base/channel/test1.go -m "add channel test1"
    [master e89c9fb] add channel test1
     Committer: luwenwei <luwenwei@hostname>
    您的姓名和邮件地址基于登录名和主机名进行了自动设置。请检查它们正确
    与否。您可以通过下面的命令对其进行明确地设置以免再出现本提示信息:
    
        git config --global user.name "Your Name"
        git config --global user.email you@example.com
    
    设置完毕后,您可以用下面的命令来修正本次提交所使用的用户身份:
    
        git commit --amend --reset-author
    
     1 file changed, 20 insertions(+)
     create mode 100644 go/base/channel/test1.go

    4,查看文件的状态

    [luwenwei@appdev115 ~/git/helww/labs/go]$ git status base/channel/test1.go 
    # 位于分支 master
    无文件要提交,干净的工作区

     5,git提交到远程代码库

    [luwenwei@appdev115 ~/git/helww/labs/go]$ git push origin master
    Enter passphrase for key '/home/luwenwei/.ssh/id_rsa': 
    Counting objects: 9, done.
    Delta compression using up to 2 threads.
    Compressing objects: 100% (4/4), done.
    Writing objects: 100% (6/6), 720 bytes, done.
    Total 6 (delta 0), reused 0 (delta 0)
    To git@github.com:helww/labs.git
       a2da4c2..e89c9fb  master -> master

    6,查看提交文件的状态

    [luwenwei@appdev115 ~/git/helww/labs/go]$ git status base/channel/test1.go
    # 位于分支 master
    无文件要提交,干净的工作区

     7,git add操作

    想要提交一个文件,有两种办法:A,先批量add 后commit;B,直接commit;
    
    A方案:
    git add a.txt
    git commit -m 'commit message'
    
    B方案:
    git commit a.txt -m 'commit message'
    
    但有的时候我们不小心add了些无关文件,如何撤销呢?
    git reset HEAD a.txt
  • 相关阅读:
    zoj 2812
    按1的个数排序
    输出等腰梯形
    约瑟夫环杂题
    九度oj 题目1369:字符串的排列
    .NET CORE LOG
    .NET CORE 配置
    dotnet core 数据库
    asp.net core mvc简介
    dotnet core 项目
  • 原文地址:https://www.cnblogs.com/helww/p/4692967.html
Copyright © 2011-2022 走看看