GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — learngit/Git_Note.txt at master · 521lbx/learngit

Expand file tree

/

Git_Note.txt

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
60 lines (42 loc) · 2.38 KB
/

Git_Note.txt

Copy path

File metadata and controls

60 lines (42 loc) · 2.38 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
设置用户
$ git config --global user.name "Your Name"
$ git config --global user.email "[email protected]"
git仓库设置
1.新建系统下文件夹
$ mkdir learngit
$ cd learngit
$ pwd
/Users/michael/learngit
2.设置为git仓库
$ git init
Initialized empty Git repository in /Users/michael/learngit/.git/
$ git status 库状态 (1.可查看现在的库信息修改状态,提交后查看不到;2.可用来查看已add将要被commit的信息)
$ git diff 修改文件名,含扩展名 (查看修改文件的详细信息)
$ git add 文件名,含扩展名
$ git commit -m "(修改日志)"
$ git log 库提交信息
$ git reset --hard commit_id 库回退
$ git reflog 库命令记录
add 暂存区
commit 版本库
场景1:当你改乱了工作区某个文件的内容,想直接丢弃工作区的修改时,用命令git checkout -- file。
场景2:当你不但改乱了工作区某个文件的内容,还添加到了暂存区时,想丢弃修改,分两步,第一步用命令git reset HEAD <file>,就回到了场景1,第二步按场景1操作。
场景3:已经提交了不合适的修改到版本库时,想要撤销本次提交,参考版本回退一节,不过前提是没有推送到远程库。
$ git rm 文件名 从暂存区删除文件
$ git checkout -- 文件名
删错了,因为版本库里还有,所以可以把误删的文件恢复到最新版本:
要关联一个远程库,使用命令git remote add origin git@server-name:path/repo-name.git;
关联后,使用命令git push -u origin master第一次推送master分支的所有内容;
此后,每次本地提交后,只要有必要,就可以使用命令git push origin master推送最新修改;
要克隆一个仓库,首先必须知道仓库的地址,然后使用git clone命令克隆。
Git支持多种协议,包括https,但通过ssh支持的原生git协议速度最快。
Git鼓励大量使用分支:
查看分支:git branch
创建分支:git branch <name>
切换分支:git checkout <name>
创建+切换分支:git checkout -b <name>
合并某分支到当前分支:git merge <name>
删除分支:git branch -d <name>
当Git无法自动合并分支时,就必须首先解决冲突。解决冲突后,再提交,合并完成。
解决冲突就是把Git合并失败的文件手动编辑为我们希望的内容,再提交。
用git log --graph命令可以看到分支合并图。
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.