git学习


用户签名的设置 全局名称和邮箱

Administrator@DESKTOP-27HOQJ5 MINGW64 ~/Desktop
$ git config --global user.name torchstXX

Administrator@DESKTOP-27HOQJ5 MINGW64 ~/Desktop
$ git config --global user.email 138448XXX@163.com

 初始化本地库

$ git init
Initialized empty Git repository in G:/git-demo/.git/

Administrator@DESKTOP-27HOQJ5 MINGW64 /g/git-demo (master)

$ ls -alh
total 28K
drwxr-xr-x 1 Administrator 197121 0 11月 25 22:18 ./
drwxr-xr-x 1 Administrator 197121 0 11月 25 22:18 ../
drwxr-xr-x 1 Administrator 197121 0 11月 25 22:18 .git/

Administrator@DESKTOP-27HOQJ5 MINGW64 /g/git-demo (master)
$ git status
On branch master

No commits yet

nothing to commit (create/copy files and use "git add" to track)

Administrator@DESKTOP-27HOQJ5 MINGW64 /g/git-demo (master)

  添加暂存区

Administrator@DESKTOP-27HOQJ5 MINGW64 /g/git-demo (master)
$ git add hello.txt
warning: LF will be replaced by CRLF in hello.txt.
The file will have its original line endings in your working directory

Administrator@DESKTOP-27HOQJ5 MINGW64 /g/git-demo (master)
$ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached ..." to unstage)

        new file:   hello.txt


Administrator@DESKTOP-27HOQJ5 MINGW64 /g/git-demo (master)

  提交本地库

$ git commit -m "first commit" hello.txt
warning: LF will be replaced by CRLF in hello.txt.
The file will have its original line endings in your working directory
[master (root-commit) b72495e] first commit
 1 file changed, 4 insertions(+)
 create mode 100644 hello.txt

Administrator@DESKTOP-27HOQJ5 MINGW64 /g/git-demo (master)
$ git status
On branch master
nothing to commit, working tree clean

Administrator@DESKTOP-27HOQJ5 MINGW64 /g/git-demo (master)

  查看提交记录

$ git reflog
b72495e (HEAD -> master) HEAD@{0}: commit (initial): first commit

Administrator@DESKTOP-27HOQJ5 MINGW64 /g/git-demo (master)
$ git log
commit b72495ea94c83460df1f02079fe8cd5f79a5707d (HEAD -> master)
Author: torchstar <13844826204@163.com>
Date:   Thu Nov 25 22:42:10 2021 +0800

    first commit

Administrator@DESKTOP-27HOQJ5 MINGW64 /g/git-demo (master)

  修改文件

$ vim hello.txt

Administrator@DESKTOP-27HOQJ5 MINGW64 /g/git-demo (master)
$ git status
On branch master
Changes not staged for commit:
  (use "git add ..." to update what will be committed)
  (use "git checkout -- ..." to discard changes in working directory)

        modified:   hello.txt

no changes added to commit (use "git add" and/or "git commit -a")

Administrator@DESKTOP-27HOQJ5 MINGW64 /g/git-demo (master)
$ git add hello.txt
warning: LF will be replaced by CRLF in hello.txt.
The file will have its original line endings in your working directory

Administrator@DESKTOP-27HOQJ5 MINGW64 /g/git-demo (master)
$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD ..." to unstage)

        modified:   hello.txt


Administrator@DESKTOP-27HOQJ5 MINGW64 /g/git-demo (master)
$ git commit hello.txt
warning: LF will be replaced by CRLF in hello.txt.
The file will have its original line endings in your working directory
[master 079e3b5] test Please enter the commit message for your changes. Lines starting
 1 file changed, 3 insertions(+)

Administrator@DESKTOP-27HOQJ5 MINGW64 /g/git-demo (master)
$ git status
On branch master
nothing to commit, working tree clean

Administrator@DESKTOP-27HOQJ5 MINGW64 /g/git-demo (master)
$ git log
commit 079e3b5643e67df34cfb05ce3965dae4e8a69bba (HEAD -> master)
Author: torchstar <13844826204@163.com>
Date:   Thu Nov 25 22:55:22 2021 +0800

    test Please enter the commit message for your changes. Lines starting

commit b72495ea94c83460df1f02079fe8cd5f79a5707d
Author: torchstar <13844826204@163.com>
Date:   Thu Nov 25 22:42:10 2021 +0800

    first commit

Administrator@DESKTOP-27HOQJ5 MINGW64 /g/git-demo (master)
$ git reflog
079e3b5 (HEAD -> master) HEAD@{0}: commit: test Please enter the commit messagefor your changes. Lines starting
b72495e HEAD@{1}: commit (initial): first commit

Administrator@DESKTOP-27HOQJ5 MINGW64 /g/git-demo (master)