CNPM Binaries Mirror (npmmirror.com)https://registry.npmmirror.com/binary.html?path=git-for-windows/
#用于输出git提交日志
alias git-log='git log --all --pretty=oneline --graph --abbrev-commit'
#用于输出当前目录所有文件及基本信息
alias ll='ls -a1'
- 1. 新建一个text.txt
- ----------------------------------------------------------
- $ touch text.txt
-
-
- 2. 往text.txt中写入字符串并查看
- ----------------------------------------------------------
- $ vim text.txt
-
- $ cat text.txt
- hello git
-
-
- 3. add操作
- ----------------------------------------------------------
- $ git add .
- warning: LF will be replaced by CRLF in text.txt.
- The file will have its original line endings in your working directory
-
-
- 4. 查看文件状态
- ----------------------------------------------------------
- $ git status
- On branch master
-
- No commits yet
-
- Changes to be committed:
- (use "git rm --cached
..." to unstage) - new file: text.txt
-
-
- 5. commit操作
- ----------------------------------------------------------
- $ git commit -m "第一次提交"
- [master (root-commit) 2f93118] 第一次提交
- 1 file changed, 1 insertion(+)
- create mode 100644 text.txt
-
-
- 6. 查看日志
- ----------------------------------------------------------
- $ git log
- commit 2f9311838ec6a0891840f602f780186bc31f7baa (HEAD -> master)
- Author: “gyx” <729389749@163.com>
- Date: Tue Jun 14 12:18:41 2022 +0800
-
- 第一次提交
-
-
- 7. 修改文件内容
- ----------------------------------------------------------
- $ vim text.txt
-
-
- 8. 再次add操作
- ----------------------------------------------------------
- $ git add .
- warning: LF will be replaced by CRLF in text.txt.
- The file will have its original line endings in your working directory
-
-
- 9. 再次commit操作
- ----------------------------------------------------------
- $ git commit -m "第二次提交"
- [master 3430517] 第二次提交
- 1 file changed, 1 insertion(+)
-
-
- 10. 再次查看文件状态
- ----------------------------------------------------------
- $ git status
- On branch master
- nothing to commit, working tree clean
-
-
- 11. 再次查看日志
- ----------------------------------------------------------
- $ git log
- commit 3430517a8325b59f6d5377d5c8aca6dd124e46c7 (HEAD -> master)
- Author: “gyx” <729389749@163.com>
- Date: Tue Jun 14 12:23:25 2022 +0800
-
- 第二次提交
-
- commit 2f9311838ec6a0891840f602f780186bc31f7baa
- Author: “gyx” <729389749@163.com>
- Date: Tue Jun 14 12:18:41 2022 +0800
-
- 第一次提交
-
-
- 12. 版本回退
- ----------------------------------------------------------
- $ git reset --hard 2f9311838ec6a0891840f602f780186bc31f7baa
- HEAD is now at 2f93118 第一次提交
-
-
- 13. 查看版本
- ----------------------------------------------------------
- $ cat text.txt
- hello git
-
-
- 14. 版本回退
- ----------------------------------------------------------
- $ git reset --hard 3430517a8325b59f6d5377d5c8aca6dd124e46c7
- HEAD is now at 3430517 第二次提交
-
-
- 15. 查看版本
- ----------------------------------------------------------
- $ cat text.txt
- hello git
- hello git2
-
-
- 16. 清屏
- ----------------------------------------------------------
- $ clear
-
-
- 17. 清除后查看版本
- ----------------------------------------------------------
- $ git reflog
- 3430517 (HEAD -> master) HEAD@{0}: reset: moving to 3430517a8325b59f6d5377d5c8aca6dd124e46c7
- 2f93118 HEAD@{1}: reset: moving to 2f9311838ec6a0891840f602f780186bc31f7baa
- 3430517 (HEAD -> master) HEAD@{2}: commit: 第二次提交
- 2f93118 HEAD@{3}: commit (initial): 第一次提交
-
-
- 18. 版本回退
- ----------------------------------------------------------
- $ git reset --hard 3430517
- HEAD is now at 3430517 第二次提交
-
-
- 19. 查看版本
- ----------------------------------------------------------
- $ cat text.txt
- hello git
- hello git2
-
生成公钥要连续三个回车才有!!!
- 1. 初始化一个本地仓库
- ----------------------------------------------------------
- $ git init
- Initialized empty Git repository in E:/java/01_WorkSpace/git/git-demo/.git/
-
-
- 2. 新增一个文件,写入字符串
- ----------------------------------------------------------
- $ touch text.txt
-
- $ vim text.txt
-
- $ cat text.txt
- hello
- java
-
-
- 3.新增远程仓库地址,并查看
- ----------------------------------------------------------
- $ git remote add origin git@gitee.com:YingXinChn/git-test.git
-
- $ git remote
- origin
-
-
- 4.添加
- ----------------------------------------------------------
- $ git add .
- warning: LF will be replaced by CRLF in text.txt.
- The file will have its original line endings in your working directory
-
-
- 5.commit
- ----------------------------------------------------------
- $ git commit -m "第一次提交"
- [master (root-commit) 1589a5a] 第一次提交
- 1 file changed, 2 insertions(+)
- create mode 100644 text.txt
-
-
- 6.push
- ----------------------------------------------------------
- $ git push origin master
- The authenticity of host 'gitee.com (212.64.63.215)' can't be established.
- ED25519 key fingerprint is SHA256:+ULzij2u99B9eWYFTw1Q4ErYG/aepHLbu96PAUCoV88.
- This key is not known by any other names
- Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
- Warning: Permanently added 'gitee.com' (ED25519) to the list of known hosts.
- Enumerating objects: 3, done.
- Counting objects: 100% (3/3), done.
- Writing objects: 100% (3/3), 237 bytes | 118.00 KiB/s, done.
- Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
- remote: Powered by GITEE.COM [GNK-6.3]
- To gitee.com:YingXinChn/git-test.git
- * [new branch] master -> master
- 1. 克隆到本地
- ----------------------------------------------------------
- $ git clone git@gitee.com:YingXinChn/git-test.git
- Cloning into 'git-test'...
- remote: Enumerating objects: 5, done.
- remote: Counting objects: 100% (5/5), done.
- remote: Compressing objects: 100% (3/3), done.
- remote: Total 5 (delta 0), reused 0 (delta 0), pack-reused 0
- Receiving objects: 100% (5/5), done.
-
-
- 2. 进入克隆的本地仓库
- ----------------------------------------------------------
- $ cd git-test
-
-
- 3. 查看日志
- ----------------------------------------------------------
- $ git-log
- * 8399698 (HEAD -> master, origin/master, origin/HEAD) add text02
- * 0e55e86 add text01
-
-
- 4. 抓取(不合并)
- ----------------------------------------------------------
- $ git fetch
- remote: Enumerating objects: 3, done.
- remote: Counting objects: 100% (3/3), done.
- remote: Compressing objects: 100% (2/2), done.
- remote: Total 2 (delta 0), reused 0 (delta 0), pack-reused 0
- Unpacking objects: 100% (2/2), 224 bytes | 2.00 KiB/s, done.
- From gitee.com:YingXinChn/git-test
- 8399698..38e4014 master -> origin/master
-
-
- 5. 查看日志(此时没有合并到本地master分支)
- ----------------------------------------------------------
- $ git-log
- * 38e4014 (origin/master, origin/HEAD) add text03
- * 8399698 (HEAD -> master) add text02
- * 0e55e86 add text01
-
-
- 6. 合并分支
- ----------------------------------------------------------
- $ git merge origin/master
- Updating 8399698..38e4014
- Fast-forward
- text03.txt | 0
- 1 file changed, 0 insertions(+), 0 deletions(-)
- create mode 100644 text03.txt
-
-
- 7. 再次查看日志,合并成功
- ----------------------------------------------------------
- $ git-log
- * 38e4014 (HEAD -> master, origin/master, origin/HEAD) add text03
- * 8399698 add text02
- * 0e55e86 add text01