Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

常用 git 命令 #49

Open
imfenghuang opened this issue Jun 26, 2024 · 0 comments
Open

常用 git 命令 #49

imfenghuang opened this issue Jun 26, 2024 · 0 comments

Comments

@imfenghuang
Copy link
Owner

imfenghuang commented Jun 26, 2024

创建空白分支

git checkout --orphan <branch name>
git rm -rf .
git add filename
git commit -m "commit something"
git push <远程主机名> <本地分支名>:<远程分支名>
# 如果本地分支名与远程分支名相同,则可以省略冒号:
# git push <远程主机名> <本地分支名>

Tag

# https://git-scm.com/book/zh/v2/Git-%E5%9F%BA%E7%A1%80-%E6%89%93%E6%A0%87%E7%AD%BE
# 打标签 - 轻量标签
git tag <tagname>
# 打标签 - 附注标签
git tag -a <tagname> -m "xxx"
# 推到远端
git push origin <tagname>
# 删除标签
git tag -d <tagname>
# 删除标签 - 远端
git push origin --delete <tagname>
# 检出标签
git checkout  -b <new-branch> <tagname>
# git checkout -b version-2 0.0.2
# Switched to a new branch 'version-2'

push existing repository

git remote add origin <repo>
git branch -M main
git push -u origin main

移除历史记录的提交

git checkout --orphan xxx_branch
git add -A
git commit -m "xxx"
git branch -D main
git branch -m main
git push -f origin main

隐私政策

# git config --global user.email "{ID}+{username}@users.noreply.github.com"
git config user.email "{ID}+{username}@users.noreply.github.com"
git commit --amend --reset-author --no-edit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant