Skip to main content

Git常用命令集

修改本地分支名#

git branch -m $old_branch $new_branch

删除远程分支#

git push origin :$branch_name

配置远端地址#

vi .git-credentials
http://lanten:lanten@xxx.com

还原到指定版本#

# 本地还原,同步到远端需要强制git reset --hard $版本号
# 强制同步到远端git push -f

强制合并分支#

git checkout dev
# 将本地 dev 推向远程 master 分支git push origin dev:master -f

Tag#

# 添加标签git tag $TAG_NAME
# 添加标签带注释git tag -a $TAG_NAME -m "${COMMEN}"
# 推送标签:git push origin $TAG_NAME
# 删除本地标签:git tag -d $TAG_NAME
# 删除远程标签:git push origin :refs/tags/$TAG_NAME