xgqfrms / git

git all in one
https://git.xgqfrms.xyz
MIT License
2 stars 1 forks source link

git 实验 #27

Open xgqfrms opened 3 years ago

xgqfrms commented 3 years ago

git 实验

https://www.lanqiao.cn/courses/4/learning/

http://gitbook.liuhui998.com/

https://github.com/liuhui998/gitbook

xgqfrms commented 3 years ago

https://github.com/schacon/gitbook

xgqfrms commented 3 years ago

canvas

terminal UI

$ git --version[15:31:37]
# git version 2.7.4

image

$ ls -al

$ cat package.json

@theia/cli

xgqfrms commented 3 years ago

@theia/cli

https://www.npmjs.com/package/@theia/cli

https://npm.io/package/@theia/cli

Build your own IDE

https://theia-ide.org/docs/composing_applications/

Eclipse Theia is a cloud & desktop IDE framework implemented in TypeScript

Eclipse Theia是使用TypeScript实现的云和桌面IDE框架


{
  "private": true,
  "dependencies": {
    "@theia/callhierarchy": "next",
    "@theia/file-search": "next",
    "@theia/git": "next",
    "@theia/markers": "next",
    "@theia/messages": "next",
    "@theia/mini-browser": "next",
    "@theia/navigator": "next",
    "@theia/outline-view": "next",
    "@theia/plugin-ext-vscode": "next",
    "@theia/preferences": "next",
    "@theia/preview": "next",
    "@theia/search-in-workspace": "next",
    "@theia/terminal": "next"
  },
  "devDependencies": {
    "@theia/cli": "next"
  }
}

https://github.com/eclipse-theia/theia

https://github.com/eclipse-theia/theia/blob/master/dev-packages/cli/README.md

xgqfrms commented 3 years ago

https://che-incubator.github.io/vscode-theia-comparator/status.html

xgqfrms commented 3 years ago

SVN vs Git

image

image

xgqfrms commented 3 years ago

https://git-scm.com/doc

xgqfrms commented 3 years ago
$ git config --global user.name "xgqfrms"
$ git config --global user.email "xgqfrms@gmail.com"

```sh

$ vim .gitconfig

email = xgqfrms@ufo.com

name = xgqfrms

$ cat .gitconfig

https://github.com/shiyanlou/gitproject

xgqfrms commented 3 years ago

error: key does not contain a section: email
error: key does not contain a section: name

[core] ??? [user]

https://stackoverflow.com/questions/45174228/git-error-key-does-not-contain-a-section

https://www.thetopsites.net/article/52099522.shtml

https://community.atlassian.com/t5/Bitbucket-questions/Can-t-get-past-error-message-when-trying-to-git-global-config/qaq-p/1016926

image

https://community.atlassian.com/t5/Git-questions/error-msg-key-does-not-contain-a-section-trustexitcode/qaq-p/69602

$ vim ~/.gitconfig

# email = xgqfrms@ufo.com
# name = xgqfrms

[user]
  email = xxx@xxx.com
  name = xgqfrms

$ cat ~/.gitconfig

$ git config --global --edit

# git config -g -e ???

[user] + [core]

# inner local project
$ vim .git/config

[core]
  repositoryformatversion = 0
  filemode = true
  bare = false
  logallrefupdates = true

[user]
  name = xgqfrms
  email = xgqfrms@ufo.com

$ cat .git/config

https://www.codegrepper.com/code-examples/whatever/git+config+--global+%E2%80%93list+error%3A+key+does+not+contain+a+section%3A+%E2%80%93list

xgqfrms commented 3 years ago
$ git diff --cached

image

xgqfrms commented 3 years ago

git section

[core] + [user]

[core]
  repositoryformatversion = 0
  filemode = true
  bare = false
  logallrefupdates = true

[user]
  name = xgqfrms
  email = xgqfrms@xgqfrms.xyz
xgqfrms commented 3 years ago

image

xgqfrms commented 3 years ago

git merge -m "" dev

$ git merge -m 'merge experimental branch' experimental
xgqfrms commented 3 years ago

git commit -a -m "" === git commit -a (add) + git -m "" ❌👎

git commit -a -m "" === git commit -a (--all) + git -m "" ✅👍

git commit -a -m ""

$ git commit -a -m 'update file3 on master'
xgqfrms commented 3 years ago

what's git commit -a -m meanings?

git commit -a -m

-a === --all

-m === --message

$ git commit -h 
usage: git commit [<options>] [--] <pathspec>...

    -q, --quiet           suppress summary after successful commit
    -v, --verbose         show diff in commit message template

Commit message options
    -F, --file <file>     read message from file
    --author <author>     override author for commit
    --date <date>         override date for commit
    -m, --message <message>
                          commit message
    -c, --reedit-message <commit>
                          reuse and edit message from specified commit
    -C, --reuse-message <commit>
                          reuse message from specified commit
    --fixup <commit>      use autosquash formatted message to fixup specified commit
    --squash <commit>     use autosquash formatted message to squash specified commit
    --reset-author        the commit is authored by me now (used with -C/-c/--amend)
    -s, --signoff         add Signed-off-by:
    -t, --template <file>
                          use specified template file
    -e, --edit            force edit of commit
    --cleanup <mode>      how to strip spaces and #comments from message
    --status              include status in commit message template
    -S, --gpg-sign[=<key-id>]
                          GPG sign commit

Commit contents options
    -a, --all             commit all changed files
    -i, --include         add specified files to index for commit
    --interactive         interactively add files
    -p, --patch           interactively add changes
    -o, --only            commit only specified files
    -n, --no-verify       bypass pre-commit and commit-msg hooks
    --dry-run             show what would be committed
    --short               show status concisely
    --branch              show branch information
    --ahead-behind        compute full ahead/behind values
    --porcelain           machine-readable output
    --long                show status in long format (default)
    -z, --null            terminate entries with NUL
    --amend               amend previous commit
    --no-post-rewrite     bypass post-rewrite hook
    -u, --untracked-files[=<mode>]
                          show untracked files, optional modes: all, normal, no. (Default: all)
xgqfrms commented 3 years ago

git 删除分支

$ git branch -d experimental
$ git branch –D test

git branch -d 只能删除那些已经被当前分支的合并的分支. git branch –D 如果你要强制删除某个分支

xgqfrms commented 3 years ago

撤销一个合并

$ git reset --hard HEAD^
xgqfrms commented 3 years ago

快速向前合并 还有一种需要特殊对待的情况,在前面没有提到。通常,一个合并会产生一个合并提交(commit), 把两个父分支里的每一行内容都合并进来。

但是,如果当前的分支和另一个分支没有内容上的差异,就是说当前分支的每一个提交(commit)都已经存在另一个分支里了,Git 就会执行一个 快速向前(fast forward)操作;Git 不创建任何新的提交(commit),只是将当前分支指向合并进来的分支。

xgqfrms commented 3 years ago

reset 撤销

$ git reset --hard HEAD^
xgqfrms commented 3 years ago

log

$ git log

$ git log --stat 

格式化日志输出

$ git log --pretty=oneline

$ git log --pretty=short

$ git log --pretty=medium
$ git log --pretty=full
$ git log --pretty=fuller
$ git log --pretty=email 
$ git log --pretty=raw

也可用 medium,full,fuller,email 或 raw 格式; 也可以用 --pretty=format 参数定义格式

可视化

--graph 选项可以可视化你的提交图(commit graph) 会用ASCII字符来画出一个很漂亮的提交历史(commit history)线

$ git log --graph --pretty=oneline
xgqfrms commented 3 years ago

日志排序

日志记录可以按不同的顺序来显示。如果你要指定一个特定的顺序,可以为 git log 命令添加顺序参数。

按默认情况,提交会按逆时间顺序显示,可以指定 --topo-order 参数,让提交按拓扑顺序来显示(就是子提交在它们的父提交前显示):

$ git log --pretty=format:'%h : %s' --topo-order --graph

你也可以用 --reverse 参数来逆向显示所有提交日志。

xgqfrms commented 3 years ago

基本命令:

git config:配置相关信息 git clone:复制仓库 git init:初始化仓库 git add:添加更新内容到索引中 git diff:比较内容 git status:获取当前项目状况 git commit:提交 git branch:分支相关 git checkout:切换分支 git merge:合并分支 git reset:恢复版本 git log:查看日志

xgqfrms commented 3 years ago

must config before commit

$ git config --global user.email "you@example.com"
$ git config --global user.name "Your Name"
xgqfrms commented 3 years ago
$ git diff

$ git diff master test
xgqfrms commented 3 years ago

分布式的工作流程

https://www.lanqiao.cn/courses/4/learning/?id=22

xgqfrms commented 3 years ago
# 进入到临时目录
$ cd /tmp
# 克隆git仓库
$ git clone /home/shiyanlou/gitproject myrepo
$ ls -l myrepo
$ cd /tmp/myrepo

# 添加新的文件newfile
$ echo "newcontent" > newfile

# 提交修改
$ git add newfile
$ git commit -m "add newfile"
$ cd /home/shiyanlou/gitproject
$ git pull /tmp/myrepo master
xgqfrms commented 2 years ago

vscode terminal show git branch

https://www.cnblogs.com/xgqfrms/p/15423915.html