git - 忽略提交的文件和切换分支 [英] git - ignoring commited files and switch branch
问题描述
我有本地回购和远程,说上游。在远程回购中,一些基本的配置会说file1.txt和file2.txt,我将更改分支到some_branch,并输入:
I have local repo and remote, say "upstream". In remote repo some basic configs say "file1.txt" and "file2.txt", I pull changes to branch "some_branch", and typed:
git update-index --assume-unchanged file1.txt
git update-index --assume-unchanged file2.txt
以允许修改这些文件,添加一些修改与我的本地修改,我不想提交。
to allow modify this files, add some changes with my local changes, which I do not want to commit.
After在上游添加了分支somefeature
After that in "upstream" was added branch "somefeature"
fetch upstream somefeature:somefeature
并尝试:
and try:
$git checkout somefeature
error: Your local changes to the following files would be overwritten by checkout:
file1.txt
file2.txt
Please, commit your changes or stash them before you can switch branches.
Aborting
$git checkout -f somefeature
error: Entry 'file1.txt' not uptodate. Cannot merge.
然后我试试:
then I try:
$git stash
No local changes to save
$git stash -u
No local changes to save
$git update-index --no-assume-unchanged .
Ignoring path
我也尝试过--skip-worktree,但也不成功。
also I tried "--skip-worktree", but unsuccessfully also.
因此,我可以如何跳过本地更改(使用add或commit -a),但能够更改分支,并将此隐藏更改应用于其他分支,创建不是从当前?
So, how I can skip local changes whan use "add" or "commit -a", but be able to change branch, and apply this hidden changes to unother branches, created not from current?
推荐答案
要隐藏一切尝试:
To stash everything try:
git stash save --all --no-keep-index
这篇关于git - 忽略提交的文件和切换分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!