Comments (9)
如何删除 Git 仓库所有提交历史记录
删除 .git
文件夹可能会导致您的 git 存储库中的问题。如果要删除所有提交历史记录,但将代码保持在当前状态,则执行以下操作非常安全:
1, Checkout
git checkout --orphan latest_branch
2, Add all the files
git add -A
3, Commit the changes
git commit -am "commit message"
4, Delete the branch
git branch -D master
5, Rename the current branch to master
git branch -m master
6, Finally, force update your repository
git push -f origin master
PS:这不会保留你的旧的提交历史; 详情参见 how to delete all commit history in github? [duplicate]。
from jadeblog-backups.
Problem:You have not concluded your merge (MERGE_HEAD exists)
Solve:
git merge --abort [Since git version 1.7.4]
git reset --merge [prior git versions]
from jadeblog-backups.
git 如何删除本地所有未提交的更改?
如果所有更改,没有加入暂存区的话,可以:
git checkout . && git clean -xdf
如果你有的修改以及加入暂存区的话,那么 :
git reset --hard
git clean -xdf
from jadeblog-backups.
在 Mac必备软件渐集之ZSH-终极Shell 一文的评论 issues37 中有强求的推荐使用 oh-my-zsh
;
如果您使用了她,那么这份 git.plugin.zsh 配置, 对你来说,肯定也会是让你欣喜的礼物
from jadeblog-backups.
Git 取消修改,恢复版本 命令大全
取消对文件的修改。还原到最近的版本,废弃本地做的修改。
git checkout --
取消已经暂存的文件。即,撤销先前"git add"的操作
git reset HEAD ...
修改最后一次提交。用于修改上一次的提交信息,或漏提交文件等情况。
git commit --amend
回退所有内容到上一个版本
git reset HEAD^
回退 xx.py 这个文件的版本到上一个版本
git reset HEAD^ xx.py
向前回退到第 3 个版本
git reset –soft HEAD~3
将本地的状态回退到和远程的一样
git reset –hard origin/master
回退到某个版本
git reset 057d
回退到上一次提交的状态,按照某一次的commit完全反向的进行一次commit.(代码回滚到上个版本,并提交git)
git revert HEAD
from jadeblog-backups.
Git 同时 push 到多个仓库(同步)
为防止一个git仓库由于各种原因造成无法访问,可以将代码push到多个仓库。编辑本地仓库目录下面的 .git 目录下的 config 文件(命令:vim ./git/config
)。添加类如以下命令:
[remote "all"]
url = [email protected]:licess/licess.git
url = [email protected]:licess/licess.git
再 push 时,运行如下命令即可:
git push all master
from jadeblog-backups.
如何切换多个 GitHub 账号
Git 共有三个级别的 config文 件,分别是 system、global和 local。可以使用 git config --list | grep user
(windows 需用 sls 替换 grep)来查看配置;当 git commit
时,Author 信息依次读取local、global和system的配置,如果找到则不再继续读取。其他配置的读取顺序也是如此。更改配置可运行:git config --local user.name your-name
,更多详情可查看 这里。
from jadeblog-backups.
Git 删除某次错误的提交以及记录?
git reset --hard <commit_id>
git push origin HEAD --force
from jadeblog-backups.
从存储库中删除敏感数据
git filter-branch --commit-filter '
if [ "$GIT_AUTHOR_EMAIL" = "your-secret-email" ];
then
GIT_AUTHOR_NAME="your-can-be-known-name";
GIT_AUTHOR_EMAIL="your-can-be-known-email";
GIT_COMMITTER_NAME="your-can-be-known-name";
GIT_COMMITTER_EMAIL="your-can-be-known-email";
git commit-tree "$@";
else
git commit-tree "$@";
fi' HEAD
具体可参见:Removing sensitive data from a repository。
from jadeblog-backups.
Related Issues (20)
- 优质网站同好者周刊(第 42 期)- 倾城之链 | 晚晴幽草轩
- 所历前端“姿势”更替记(其一) | 晚晴幽草轩
- 关于“清风明月阁”的由来,以及未来 | 晚晴幽草轩
- 优质网站同好者周刊(第 50 期)- 倾城之链 | 晚晴幽草轩
- 优质网站同好者周刊(第 41 期)- 倾城之链 | 晚晴幽草轩
- 优质网站同好者周刊(第 49 期)- 倾城之链 | 晚晴幽草轩
- 关于加班这件事儿的随想 | 晚晴幽草轩 HOT 1
- 优质网站同好者周刊(第 45 期)- 倾城之链 | 晚晴幽草轩
- 如何制作 Google 自适应广告素材? | 晚晴幽草轩
- 优质网站同好者周刊(第 48 期)- 倾城之链 | 晚晴幽草轩
- 如何打造体验良好的本地全文搜索? | 晚晴幽草轩
- 优质网站同好者周刊(第 43 期)- 倾城之链 | 晚晴幽草轩
- 地表最强 Markdown 文本编辑工具——Obsidian | 晚晴幽草轩
- 2022,值得学习系列之:函数式编程 | 晚晴幽草轩
- 2022,如何优雅学习前端开发? | 晚晴幽草轩
- 优质网站同好者周刊(第 46 期)- 倾城之链 | 晚晴幽草轩
- 2022,「倾城之链」运营第 6 年感记 | 晚晴幽草轩
- 如何基于 Prerender 为 SPA 做 SEO 优化 | 晚晴幽草轩
- 为什么说 WebAssembly 让 Web 的未来更光明? | 晚晴幽草轩
- 近十年新兴行业技术,及简单介绍 | 晚晴幽草轩
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jadeblog-backups.