Git使用-极简工作流

2024/04/20 | 字数521 | 阅读2分钟


工作流

Git极简工作流

这是一个Git极简工作流,对于刚刚上手Git的小伙伴很实用。

  1. 下载代码(clone):git clone <your-repo-url>
  2. 创建分支(branch):git checkout -b dev
  3. 修改代码(CRUD):vim file1; touch file2
  4. 查看状态:git status -s
  5. 添加到暂存区或删除:git add <file or directory>; git rm <file>; git rm -r <directory>
  6. 提交代码(commit):git commit -m "commit msg"
  7. 推送代码(push):git push origin HEAD:main

除此之外,还有2条命令,和Git修改代码无关,只想看看谁在修改代码,修改了哪些代码,可以通过下面的命令实现(高亮部分):

bash
 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
## show history
$ git log --name-status

commit baa818089f9721eba6b10f4326e0c25d0ce1cf33 (HEAD -> main, origin/main, origin/HEAD)
Author: ticktechman <geek.wystan@gmail.com>
Date:   2024-04-03 19:46:27 +0800

    DS_Store

M    mac-defaults.sh

## show details of one commit 
$ git show baa818089f9721eba6b10f4326e0c25d0ce1cf33

commit baa818089f9721eba6b10f4326e0c25d0ce1cf33 (HEAD -> main, origin/main, origin/HEAD)
Author: ticktechman <geek.wystan@gmail.com>
Date:   2024-04-03 19:46:27 +0800

    DS_Store

diff --git a/mac-defaults.sh b/mac-defaults.sh
index 3070b28..19bdb8c 100644
--- a/mac-defaults.sh
+++ b/mac-defaults.sh
@@ -213,6 +213,12 @@ function defaults.finder.set() {
   ## don't show recent tags in sidebar
   defaults write com.apple.finder ShowRecentTags -bool false

+  ## don't write .DS_Store file on network volumns
+  defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
+
+  ## don't write .DS_Store file on local volumns
+  defaults write com.apple.desktopservices DSDontWriteLocalDotFiles true
+
   ## change list view font & icon size
   /usr/libexec/PlistBuddy -c "Set :StandardViewSettings:ExtendedListViewSettingsV2:textSize 14" ~/Library/Preferences/com.apple.finder.plist
   /usr/libexec/PlistBuddy -c "Set :StandardViewSettings:ExtendedListViewSettingsV2:iconSize 32" ~/Library/Preferences/com.apple.finder.plist
上一篇:Git基本概念-其它 下一篇:Git常见问题-如何放弃本地修改

【文章不错,鼓励一下】