Skip to content

Commit 023bc96

Browse files
author
ext.zhangpeng7
committed
git仓库迁移方法
1 parent 4d98945 commit 023bc96

File tree

5 files changed

+31
-3
lines changed

5 files changed

+31
-3
lines changed

.DS_Store

0 Bytes
Binary file not shown.

git通常用法.md

+31-3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
- `git checkout v0.21` 此时会指向打 v0.21 标签时的代码状态
6666
- `git checkout -b new v1.0` 创建分支 new,将 1.0 的代码拉过去
6767
- `git checkout -b pre origin/pre` 拉取远程特定分支 origin/pre 到本地分支 pre 上
68+
- `git checkout --orphan branchname` 基于当前分支创建新分支,且新分支上没有当前分支的 commit log
6869
- `git push origin --delete tag <tagname>`删除远程 tag
6970
- `git tag -d <tagname>` 删除本地 tag
7071

@@ -268,12 +269,13 @@
268269
1. 先更新/提交子模块代码,提交, push
269270
2. 再更新主项目
270271

271-
#### 修改命令
272+
#### git 配置
272273

273274
- `git config --global alias.co checkout`
274275
- `git config --global alias.ci commit`
275276
- `git config --global alias.sta status` 命令别名
276277
- `git config apply.whitespace nowarn` 忽略空格的改变
278+
- `git config --global credential.helper store` 永久存储密码, 避免每次都重新输入账号密码
277279

278280
## 流程
279281

@@ -298,6 +300,32 @@
298300
- cd 到项目目录下, cd .git/ 更改 conf 中的 ip 或 url
299301
- push 到新的仓库
300302

303+
`如何让新仓库不包含原仓库的commit`
304+
305+
- 1.从最全代码分支,切换出新的分支, 新分支不包含任何原来的 commit
306+
307+
`git checkout --orphan branchname`
308+
309+
- 2.缓存所有文件(除了.gitignore 中声明排除的)
310+
311+
`git add -A`
312+
313+
- 3.提交跟踪过的文件(Commit the changes)
314+
315+
`git commit -am "commit message"`
316+
317+
- 4.删除 master 分支(Delete the branch)
318+
319+
`git branch -D master`
320+
321+
- 5.重命名当前分支为 master(Rename the current branch to master)
322+
323+
`git branch -m master`
324+
325+
- 6.提交到远程 master 分支 (Finally, force update your repository)
326+
327+
`git push -f origin master`
328+
301329
#### 注意
302330

303331
- 本机和远程的相同分支使用 rebase。如果是不同分支的合并则必须用 merge,否则会导致历史记录不可读,因为再也找不到合并之前各个分支到底是在哪里[地址](http://www.toobug.net/article/git_and_gitflow.html)
@@ -318,7 +346,7 @@
318346

319347
#### 常见问题
320348

321-
1. 放弃跟踪项目中的文件
349+
1. 放弃跟踪项目中的文件
322350

323351
gitignore 只能忽略那些原来没有被 track 的文件,如果某些文件已经被纳入了版本管理中,则修改.gitignore 是无效的。
324352
正确的做法是在每个 clone 下来的仓库中手动设置不要检查特定文件的更改情况。
@@ -335,6 +363,6 @@
335363
touch .gitignore //创建
336364
open .gitignore //打开
337365

338-
2. 第二种方法
366+
2. 第二种方法
339367

340368
cd 进入到根目录 .git/info 中, vi exclude文件, 直接把要忽略的内容添加进去

学习导图/.DS_Store

0 Bytes
Binary file not shown.

学习导图/前端/.DS_Store

0 Bytes
Binary file not shown.
-1.19 MB
Binary file not shown.

0 commit comments

Comments
 (0)