Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用.git中回购的实际内容替换git回购的工作副本? 太长,读不下去了_Git_Perforce_Git P4 - Fatal编程技术网

用.git中回购的实际内容替换git回购的工作副本? 太长,读不下去了

用.git中回购的实际内容替换git回购的工作副本? 太长,读不下去了,git,perforce,git-p4,Git,Perforce,Git P4,什么是git命令来强制工作副本的内容成为.git子文件夹中repo中的实际内容?(如果更改从另一台机器推送到具有工作副本的远程回购) 长话短说 我希望我的公司中使用perforce的团队迁移到git。我想使用Git-P4来实现这一点。我想将perforce的一部分克隆到git repo,并使其成为远程repo,这样人们就可以克隆它,将更改推送到远程repo,然后定期将远程repo中所做的更改重新提交给perforce。所以我遵循了这个教程 归结起来就是这个命令: git p4 clone //

什么是git命令来强制工作副本的内容成为.git子文件夹中repo中的实际内容?(如果更改从另一台机器推送到具有工作副本的远程回购)

长话短说 我希望我的公司中使用perforce的团队迁移到git。我想使用Git-P4来实现这一点。我想将perforce的一部分克隆到git repo,并使其成为远程repo,这样人们就可以克隆它,将更改推送到远程repo,然后定期将远程repo中所做的更改重新提交给perforce。所以我遵循了这个教程

归结起来就是这个命令:

git p4 clone //depot/path.to/folder@all folder
那就行了,然后在我的客户机上就行了

git clone "user1@server:/home/user1/path/to/folder"
这很好,它显示了,所以我对一个测试文件进行了编辑,然后执行

git add test7
git commit -m 'test'
git push
当我试图将其推回到远程回购时,我在客户端上得到了这个错误

git push
user1@server1's password: 
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 273 bytes, done.
Total 3 (delta 1), reused 1 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error: 
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error: 
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To user1@server1:/home/user1/path/to/folder
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'user1@server1:/home/user1/path/to/folder'
这里已经解释过了

于是我开始

git config receive.denyCurrentBranch ignore
然后再试一次,git push成功了。但这次回到远程回购,它工作正常,但当我尝试做git状态时,它会抱怨一些不同的事情

git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   deleted:    test7
#
随着时间的推移,这似乎会成为一个大问题。我不想让远程回购上的工作副本永久处于那种状态

因此,我必须找出如何使用.git文件夹中实际存储库的索引强制覆盖工作repo的内容

现在我找到了这个

谁说要这么做

git stash save --keep-index
git stash drop
还是这样做

git checkout -- .
这两个都不起作用。它们看起来好像工作了,但添加的文件仍然不在那里,git状态仍然显示由工作副本和索引之间的差异引起的未老化更改

git stash save --keep-index
Saved working directory and index state WIP on master: 38f67b9 cym: test 7 from linux
HEAD is now at 38f67b9 cym: test 7 from linux
git stash drop
Dropped refs/stash@{0} (3ce5805230e4faa3ec4dd2daa9cb65c86335e1a8)
git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   deleted:    test7
#

git checkout -- .

git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   deleted:    test7
#
git stash save--保留索引
已保存的工作目录和索引状态WIP位于linux上的主机:38f67b9 cym:test 7上
HEAD现在是来自linux的38f67b9 cym:test7
吉特储藏液
丢弃的引用/隐藏{0}(3ce5805230e4faa3ec4dd2daa9cb65c86335e1a8)
git状态
#论分行行长
#要提交的更改:
#(使用“git重置磁头…”取消分级)
#
#删除:test7
#
git签出--。
git状态
#论分行行长
#要提交的更改:
#(使用“git重置磁头…”取消分级)
#
#删除:test7
#

那么,如何强制工作副本表示repo中实际存在的内容呢?

git checkout-f
获取存储库中所有文件的最新版本<根目录中的code>git clean-f删除所有不受版本控制的文件,
git clean-f-x
还删除显式忽略的文件(在
.gitignore
文件中)。

您可以使用以下命令将头部设置为任何状态:


git重置--hard REFSPEC

您考虑过使用performe git Fusion吗?它基本上完成了git-p4所做的一切,但是避免了提交第二组p4工作文件。它也得到了perforce的支持。
git stash save --keep-index
Saved working directory and index state WIP on master: 38f67b9 cym: test 7 from linux
HEAD is now at 38f67b9 cym: test 7 from linux
git stash drop
Dropped refs/stash@{0} (3ce5805230e4faa3ec4dd2daa9cb65c86335e1a8)
git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   deleted:    test7
#

git checkout -- .

git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   deleted:    test7
#