git - fubd/blowfish GitHub Wiki

git clone指定Tag

it clone -b v4.1.3 --depth 1 https://github.com/twbs/bootstrap.git

创建tag
git tag <Tag名字> (默认在HEAD上面)
git tag <Tag 名字> (指定commit打tag)
git tag -a <Tag名字> -m <注释文字>

查看tag
git ls-remote --tags (远程)
git tag (本地)
git show v1.0.0 (查看tag的diff)

推送
git push origin <Tag 名字>
git push origin --tags (推送所有)

删除
git tag -d <Tag 名字>
git push origin :refs/tags/<Tag 名字>


同时创建本地和远程分支

  1. git branch <分支名> 2. git checkout <分支名> 3. git push origin <local_branch_name>:<remote_branch_name>
    (远程分支不需要加origin/, 默认查看会有)

关联本地和远程分支

git branch --set-upstream-to=origin/phase3 phase3

主分支合并到本地分支

参考:https://blog.csdn.net/pobaby/article/details/83507490
(保证主分支是commit后的干净的,再checkout到dev分支上merge)

如果远程分支已有,没有本地分支时

git fetch origin 取远程的变更即可
git branch -vv (此时仍然看不到新创建的本地分支)
git checkout <分支名> 本地分支已经自动创建, 且自动关联到远程分支

删除本地创建的多余分支

git branch -d <分支名>

删除远程分支

git push origin --delete dev

查看分支

查看本地分支git branch -vv 查看所有分支git branch -a

提交分支/拉取分支

git push origin <本地分支名>:<远程分支名> git pull origin <远程分支名>


本地覆盖远程

git push origin <分支名> -f

远程覆盖本地

  1. git fetch --all 2. git reset --hard origin/master 3. git pull origin master

各种撤回

  1. 没有add时候, git checkout .
  2. 已经add、git reset HEAD . // 从暂存区恢复到工作区 不会放弃本地更改
  3. 已经commit, git reset --hard [git log 查看id] // 注意 这会直接恢复到上一个版本放弃本地的更改, 慎用
  4. 已经commit , git reset [git log id] 或者 HEAD^ // 恢复到 工作去, 可以git add重新提交
  5. 已经 commit , git reset --soft HEAD^ // 恢复到暂存区

本地分支没改完,又要改其它分支,而且本地代码不影响其它分支 怎么办??

先把当前本地代码全部commit,再checkout其它分支

git将当前分支上修改的东西转移到新建分支

我们不需要在A分支做commit,只需要在A分支新建B分支,然后切换过去。这个时候你会发现修改的东西在A,B分支都有。这个时候在B分支commit,那么这些修改保留在B分支上,再切换到A分支上会发现修改都没有保留下来

删除敏感信息

https://zhuanlan.zhihu.com/p/35078876 如果报错ref not match , 参考:https://stackoverflow.com/questions/4181861/message-src-refspec-master-does-not-match-any-when-pushing-commits-in-git

.ignore忽略文件失败

https://stackoverflow.com/questions/30227858/gitignore-exclude-specific-file

切换分支时,暂存当前更改

https://segmentfault.com/q/1010000000184974/

使用代理和取消代理

git config --global https.proxy http://127.0.0.1:1080

git config --global https.proxy https://127.0.0.1:1080

git config --global --unset http.proxy

git config --global --unset https.proxy

重置账号密码 git config --system --unset credential.helper

⚠️ **GitHub.com Fallback** ⚠️