Git常用命令

2022-05-03 10:18:42
/
0 点赞
/
78 阅读
2022-05-03

git 常用命令

撤销add

git reset HEAD

撤销commit

git reset --soft HEAD^

切换的某个提交点

git reset commitId 重置指定提交记录id

加入新的地址

一份代码提交多个账户

git remote set-url --add origin git@github.com:aidreamwin/weilaiche_data.git

强制覆盖本地代码

git强制覆盖:
    git fetch --all
    git reset --hard origin/master
    git pull

git强制覆盖本地命令(单条执行):
    git fetch --all && git reset --hard origin/master && git pull

多分支操作

    1. push
        1. git push REMOTE '*:*'
        2. git push REMOTE --all
    2. pull
        1. git fetch --all
        2. git pull --all
//远程分支覆盖本地所有分支
git pull --all
for branch in `git branch -a | grep remotes | grep -v HEAD`; do git checkout -f -t -B ${branch##remotes/origin/} $branch; done;
git checkout master

创建tag

git tag <tagName> //创建本地tag

git push origin <tagName> //推送到远程仓库

打包

自动忽略.gitignore中文件

mkdir -p dist && git archive --format zip -o dist/aiservice-$(git rev-parse --abbrev-ref 
版权属于:

那棵树看起来生气了

本文链接:

(转载时请注明本文出处及文章链接)