将GIT本地重置为远程版本

时间:2017-03-12 11:33:35

标签: git ssh git-commit git-reset

我正在尝试重置我的Git,因为我遇到了各种各样的问题。它不允许我将几个大文件推送到我的遥控器,我不知道如何从提交中删除它们。我甚至不记得提交文件。

我的遥控器是:pmp_staging

kjlin@LAPTOP-BU6U18C6 MINGW64 /c/wamp64/www/postmyproject (master)<br>
$ git push pmp_staging master<br>
Enter passphrase for key '/c/Users/kjlin/.ssh/id_rsa':<br>
Counting objects: 7215, done.<br>
Delta compression using up to 4 threads.<br>
Compressing objects: 100% (7006/7006), done.<br>
Writing objects: 100% (7215/7215), 44.69 MiB | 1.01 MiB/s, done.<br>
Total 7215 (delta 1112), reused 0 (delta 0)<br>
remote: Resolving deltas: 100% (1112/1112), done.<br>
remote:   git.wpengine.com: validating<br>
remote:   - info: detected push to staging application ...<br>
remote:   - info: validating files in 9f1931e ...<br>
remote:   - info: found application servers ...<br>
remote:  failed...<br>
remote:   system/large file types detected:<br>
remote:   ------------------------------------------------------------------<br>
<br>
remote: wp-content/mu-plugins/wpengine-common/preamble.php<br>
remote: wp-content/mu-plugins/wpengine-common/redis-object-cache.php<br>
remote: wp-content/mu-plugins/wpengine-common/s3-uploads.php<br>
remote: wp-content/mu-plugins/wpengine-common/util.php<br>
remote: wp-content/mu-plugins/wpengine-common/views/admin-footer.php<br>
remote: wp-content/mu-plugins/wpengine-common/views/admin/advanced.php<br>
remote: wp-content/mu-plugins/wpengine-common/views/admin/debug-db.php<br>
remote: wp-content/mu-plugins/wpengine-common/views/admin/notice-sticky.php<br>
remote: wp-content/mu-plugins/wpengine-common/views/admin/notice.php<br>
remote: wp-content/mu-plugins/wpengine-common/views/general/powered-by.php<br>
remote: wp-content/mu-plugins/wpengine-common/views/modal.php<br>
remote: wp-content/mu-plugins/wpengine-common/views/staging-modal.php<br>
remote: wp-content/mu-plugins/wpengine-common/views/wpe-migration-preview-<br>template.php
remote: wp-content/mu-plugins/wpengine-common/wpe_wpdb.php<br>
remote:   ------------------------------------------------------------------
remote:   please remove these files from your source, re-commit, and push...
To git.wpengine.com:staging/postmyproject2.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to'git@git.wpengine.com:staging/postmyproject2.git'<br>

我无法弄清楚如何从原始提交中删除这些文件。我试着将头部移回原点,但似乎无法摆脱它们。相反,我想重新开始。我只是希望我的Git遥控器与我的本地匹配,所以我可以开始练习推送和提交。我在堆栈溢出时寻找的一切似乎都不起作用。

kjlin@LAPTOP-BU6U18C6 MINGW64 /c/wamp64/www/postmyproject (master)<br>
$ git fetch pmp_staging<br>
Enter passphrase for key '/c/Users/kjlin/.ssh/id_rsa':<br>
<br>
kjlin@LAPTOP-BU6U18C6 MINGW64 /c/wamp64/www/postmyproject (master)
$ git reset --hard master/master<br>
fatal: ambiguous argument 'master/master': unknown revision or path not in the working tree.<br>
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'<br>
<br>
kjlin@LAPTOP-BU6U18C6 MINGW64 /c/wamp64/www/postmyproject (master)<br>
$ git reset --hard pmp_staging/master<br>
fatal: ambiguous argument 'pmp_staging/master': unknown revision or path not in the working tree.<br>
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'



谢谢!

2 个答案:

答案 0 :(得分:2)

我使用rm -rf .git删除了我的整个git存储库。

我必须重新启动并按照WPengine's GIT Page

中的说明操作

我最初使用 Git Hub's帮助为WPengine.com设置了SSH。这使我可以获取SSH密钥并将其输入到我在WPengine.com上的安装中。

之后,我必须仔细遵循指示。我下载了一个压缩安装并粘贴到我当地的WAMP文件夹中。登录到GIT Bash并在我的/ c / wamp64 / www / my_install /文件夹下设置SSH。

我必须下载并设置允许Wordpress Core更改的.gitignore文件,因为我们实际上已经编辑了一些用于面向对象编程的文件。

然后我简单地遵循了WPengine的协议:

$ cd ~/wordpress/my_wp_install_name
$ git init .
$ git add . --all
$ git commit -m "initial commit..."

我必须忘记'添加。 --all”。

将我的安装设置为远程登台:

$ cd /c/wamp64/www/my_install
$ git remote add staging git@git.wpengine.com:staging/my_install.git

然后我部署到我的遥控器:

 $ git push staging master

到目前为止,GIT一直在努力,直到我下次搞砸了。

答案 1 :(得分:0)

从你所说的git reset --hard pmp_staging/master应该起作用,除非pmp_staging上没有主分支,这将是奇怪的。

运行git branch -a以仔细检查pmp_staging/master是否存在。