Git 列出除了 .gitignore 以外的所有文件(包括 tracked 和 untracked 的)

在执行 git ls-files 的时候,只会列出被 git 跟踪了 (tracked) 的文件,而不会列出那些新建未跟踪的文件 (untracked) ,这个时候用以下命令就可以列出除了 .gitignore 以外的所有文件(包括 tracked 和 untracked 的): 1 git ls-files --exclude-standard --cache --others 这个命令也可以简写成: 1 git ls-files --exclude-standard -c -o 或者: 1 git ls-files --exclude-standard -co 各项参数的意思(参考 Git 官方文档): -c –cached Show all files cached in Git’s index, i.e. all tracked files. (This is the default if no -c/-s/-d/-o/-u/-k/-m/–resolve-undo options are specified.) -o –others Show other (i.e. untracked) files in the output...

五月 18, 2023 · 1 分钟 · 103 字 · HCY

Git 修正中文乱码

在 Linux (Mac)使用 git status 或者 git ls-files 的时候,若 git 在显示中文文件名的时候出现类似下面这个乱码: "\321\203\321\201\321\202\320\260\320\275\320\276\320\262" 这个因为 git 默认预设之会打印出 non-ASCII 字符,对于 UTF-8 的文件名或者信息,会用 quoted octal notation 印出。 Git has always used octal utf8 display, and one way to show the actual name is by using printf in a bash shell. Since Git 1.7.10 introduced the support of unicode, this wiki page mentions: By default, git will print non-ASCII file names in quoted octal notation, i....

四月 18, 2023 · 1 分钟 · 84 字 · HCY

Git 自动化提交脚本 (bash)

我自己的: 1 2 3 4 5 6 cd $(dirname $0) cur=`date +%Y-%m-%d\ \|\ %H-%M-%S` git add -A git commit -m "$cur" git push -f origin main unset cur 网上的: 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 #!/bin/bash echo "=================" echo "auto git by JOEY" echo "======= 🤪 =========" echo -e " ▶ \033[33;1mgit add ....

三月 19, 2023 · 1 分钟 · 125 字 · HCY

Git 修改 / 添加 / 删除远程仓库

以下操作都是对管理本地的远端配置 修改远程仓库地址 1 git remote set-url origin <remote-url> 仓库路径查询查询 1 git remote -v 添加远程仓库 1 2 // 注:项目地址形式为:https://gitee.com/xxx/xxx.git或者 git@gitee.com:xxx/xxx.git git remote add origin <你的项目地址> 删除指定的远程仓库 1 git remote rm origin

二月 12, 2023 · 1 分钟 · 30 字 · HCY

Git Multi End Sync

从远端仓库获取最新代码合并到本地分支里 在日常开发中,很有可能几个终端都在开发同一个代码仓分支,导致本地分支里的代码“落后于”远端分支里的,我们需要做的就是从远端仓库获取最新代码合并到本地分支里。 git pull 获取最新代码到本地,并自动合并到当前分支,前提是已经 “git init” 首先我们用命令行 去查询当前代码仓的远端分支 1 git remote -v 然后直接去拉取并合并最新的代码(因为是直接合并,无法提前处理冲突,不推荐) 即拉取远端origin/master分支并合并到当前分支 1 git pull origin master 即拉取远端origin/test分支并合并到当前分支 1 git pull origin test git fetch + merge (需要额外的本地分支) 首先我们用命令行去查询当前代码仓的所有远端分支 1 git remote -v 然后用命令行获取最新代码到本地临时分支(自定义为tempBranch),获取到的远端分支为origin/dev 1 git fetch origin dev:tempBranch 用命令行去查看本地tempBranch分支和当前分支的版本差异 1 git diff tempBranch 接着用命令行合并本地临时分支tempBranch到当前分支 1 git merge tempBranch 最后用命令行来删除该临时分支 1 git branch -D tempBranch 这种方式需要建立并删除这个额外的本地分支 git fetch + merge (不额外建立本地分支) 首先我们用命令行去查询当前代码仓的所有远端分支 1 git remote -v 然后用命令行来获取远端的origin/dev分支的最新代码到本地(假设本地当前分支为dev) 1 git fetch origin dev 接着用命令行去查看本地dev分支和当前分支的版本差异 1 git log -p dev....

二月 11, 2023 · 1 分钟 · 126 字 · HCY