赞
踩
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.
git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/<branch> feature-0401
$ git branch --set-upstream-to=origin/feature-0401 feature-0401
Branch 'feature' set up to track remote branch 'feature' from 'origin'.
$ git pull
Already up to date. #拉取成功
git checkout -b dev origin/dev
Updating files: 100% (1762/1762), done.
Branch 'dev' set up to track remote branch 'dev' from 'origin'.
Switched to a new branch 'dev'
回退上一个版本
$ git reset --hard HEAD^
$ git reset --hard 667c54ca6fbfd63928da7fdb0592e0599ea48b79
对比master
$ git diff master
把本地master合并到当前分支
$ git merge master
查看日志是否合并成功
$ git log
强制push到当前分支对应的远程仓库
$ git push -f
至此分支合并成功
$ git fetch
remote: Enumerating objects: 22, done.
4b96281a..a6e87f74 feature -> origin/feature
84310e1f..68d4cf52 publish -> origin/publish
$ git merge origin/feature
...
#显示冲突内容
Automatic merge failed; fix conflicts and then commit the result.
#git pull相当于是从远程获取最新版本并merge到本地
git pull origin master :相当于git fetch 和 git merge
git fetch从远程获取最新的版本到本地的test分支上
之后再进行比较合并
git fetch origin master:tmp
git diff tmp
git merge tmp
git push
git reset --soft HEAD~1
将file退回到unstage区
git reset HEAD filename
git update-index --assume-unchanged filename
恢复跟踪
git update-index --no-assume-unchanged FLIE
方式一: 简单粗暴
$ git clone --bare xxx.git
Cloning into bare repository 'dispatch_front.git'...
remote: Counting objects: 1673, done.
remote: Total 1673 (delta 161), reused 1034 (delta 161)
Receiving objects: 100% (1673/1673), 6.67 MiB | 4.06 MiB/s, done.
Resolving deltas: 100% (161/161), done.
$ ls
front.git/
$ cd front.git
$ git push --mirror xxx.git
Counting objects: 22357, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (17072/17072), done.
Writing objects: 100% (22357/22357), 59.01 MiB | 2.59 MiB/s, done.
Total 22357 (delta 975), reused 22357 (delta 975)
remote: Resolving deltas: 100% (975/975), done.
To xxx.git
* [new branch] dev -> dev
* [new branch] master -> master
方式二:
仓库已做镜像的情况下
#查看地址
git remote -v
# 修改地址
git remote set-url origin https://xxx.git
git push -u origin “master”
加上–cache不希望这个文件被版本控制
git rm --cache -f .\CacheBuilderTest.java
git rm --cache -rf .\CacheBuilderTest //目录
$ git rm --cache -rf ./plugin/webview_flutter/example/android/.gradle rm 'plugin/webview_flutter/example/android/.gradle/7.1.1/dependencies-accessors/dependencies-accessors.lock' rm 'plugin/webview_flutter/example/android/.gradle/7.1.1/dependencies-accessors/gc.properties' rm 'plugin/webview_flutter/example/android/.gradle/7.1.1/fileChanges/last-build.bin' rm 'plugin/webview_flutter/example/android/.gradle/7.1.1/fileHashes/fileHashes.lock' rm 'plugin/webview_flutter/example/android/.gradle/7.1.1/gc.properties' rm 'plugin/webview_flutter/example/android/.gradle/7.4.2/checksums/checksums.lock' rm 'plugin/webview_flutter/example/android/.gradle/7.4.2/checksums/sha1-checksums.bin' rm 'plugin/webview_flutter/example/android/.gradle/7.4.2/dependencies-accessors/dependencies-accessors.lock' rm 'plugin/webview_flutter/example/android/.gradle/7.4.2/dependencies-accessors/gc.properties' rm 'plugin/webview_flutter/example/android/.gradle/7.4.2/fileChanges/last-build.bin' rm 'plugin/webview_flutter/example/android/.gradle/7.4.2/fileHashes/fileHashes.lock' rm 'plugin/webview_flutter/example/android/.gradle/7.4.2/gc.properties' rm 'plugin/webview_flutter/example/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock' rm 'plugin/webview_flutter/example/android/.gradle/buildOutputCleanup/cache.properties' rm 'plugin/webview_flutter/example/android/.gradle/checksums/checksums.lock' rm 'plugin/webview_flutter/example/android/.gradle/vcs-1/gc.properties' $ git status . On branch feature Your branch is up to date with 'origin/feature'. Changes to be committed: (use "git restore --staged <file>..." to unstage) deleted: plugin/webview_flutter/example/android/.gradle/7.1.1/dependencies-accessors/dependencies-accessors.lock deleted: plugin/webview_flutter/example/android/.gradle/7.1.1/dependencies-accessors/gc.properties deleted: plugin/webview_flutter/example/android/.gradle/7.1.1/fileChanges/last-build.bin deleted: plugin/webview_flutter/example/android/.gradle/7.1.1/fileHashes/fileHashes.lock deleted: plugin/webview_flutter/example/android/.gradle/7.1.1/gc.properties deleted: plugin/webview_flutter/example/android/.gradle/7.4.2/checksums/checksums.lock deleted: plugin/webview_flutter/example/android/.gradle/7.4.2/checksums/sha1-checksums.bin deleted: plugin/webview_flutter/example/android/.gradle/7.4.2/dependencies-accessors/dependencies-accessors.lock deleted: plugin/webview_flutter/example/android/.gradle/7.4.2/dependencies-accessors/gc.properties deleted: plugin/webview_flutter/example/android/.gradle/7.4.2/fileChanges/last-build.bin deleted: plugin/webview_flutter/example/android/.gradle/7.4.2/fileHashes/fileHashes.lock deleted: plugin/webview_flutter/example/android/.gradle/7.4.2/gc.properties deleted: plugin/webview_flutter/example/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock deleted: plugin/webview_flutter/example/android/.gradle/buildOutputCleanup/cache.properties deleted: plugin/webview_flutter/example/android/.gradle/checksums/checksums.lock deleted: plugin/webview_flutter/example/android/.gradle/vcs-1/gc.properties Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: .gitignore modified: Makefile
对应IDEA的操作就是
文件右键 -> git -> ROLLBACK
…但是执行之后,不知为何占用空间还变大了.
$ git rev-list --objects --all | grep "$(git verify-pack -v .git/objects/pack/*.idx | sort -k 3 -n | tail -5 | awk '{print$1}')"
14ad8fb385c589a25b77578bc599a95a211xxxx plugin/xxxx.so
60a278485ef346f95657eecfbc0b2c30637xxxx plugin/xxxx.so
$ git filter-branch --force --index-filter "git rm -rf --cached --ignore-unmatch android/libs/arm64-v8a/xxx.so" --prune-empty --tag-name-filter cat -- --all
WARNING: git-filter-branch has a glut of gotchas generating mangled history
rewrites. Hit Ctrl-C before proceeding to abort, then use an
alternative filtering tool such as 'git filter-repo'
(https://github.com/newren/git-filter-repo/) instead. See the
filter-branch manual page for more details; to squelch this warning,
set FILTER_BRANCH_SQUELCH_WARNING=1.
Proceeding with filter-branch...
Rewrite 0a3e88ca0a21df9d054387ac50bb1ad5ed74c129 (53/73) (4 seconds passed, remaining 1 predicted) rm 'android/libs/arm64-v8a/xxx.so'
...略
Ref 'refs/heads/feature' was rewritten
WARNING: Ref 'refs/heads/master' is unchanged
...略
这条命令使用 Git 的 filter-branch 效果重新打包 Git 的历史记录,过滤掉指定的大文件 FILENAME。
filter-branch 的作用是重写 Git 历史,可以用来修改提交记录、移除文件等。
这条命令各个选项的意思是:
–force: 强制重写历史,避免非快进合并。
–index-filter: 允许自定义过滤操作,这里使用 git rm 删除指定文件。
“git rm -rf --cached --ignore-unmatch FILENAME”: 过滤操作,删除 FILENAME 文件(需要替换为实际文件名)。
–prune-empty: 如果过滤后某次提交没有改动,则删除此空提交。
–tag-name-filter cat: 保留标签。
– --all: 重写所有分支的历史。
所以,这条 filter-branch 命令的作用是:
$ git push --force
Enumerating objects: 710, done.
Counting objects: 100% (710/710), done.
Delta compression using up to 4 threads
Compressing objects: 100% (526/526), done.
Writing objects: 100% (652/652), 53.29 MiB | 1.63 MiB/s, done.
Total 652 (delta 264), reused 264 (delta 29), pack-reused 0
remote: Resolving deltas: 100% (264/264), completed with 39 local objects.
To https://xxx.git
+ ced1890...0092ad0 feature -> feature (forced update)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。