Search code examples
gitsshgit-commitgit-reset

Resetting GIT local to remote version


I'm trying to reset my Git because I'm having all kinds of problems. It would not allow me to push several large files to my remote and I don't know how to delete them from the commit. I don't recall even committing the files.

my remote is: 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'[email protected]:staging/postmyproject2.git'<br>

I couldn't figure out how to remove these files from the original commit. I tried moving the head back to the origin but can't seem to get rid of them. Instead, I'd like to start fresh. I just want my Git remote to match my local so I can start practicing pushes and commits. Everything I look for on stack overflow doesn't seem to work.

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>...]'



Thanks!


Solution

  • I usedrm -rf .git to delete my entire git repository.

    I had to restart and followed the directions in WPengine's GIT Page

    I had initially setup an SSH for WPengine.com using Git Hub's help. This allowed me to get my SSH key and input it into my install on WPengine.com.

    After that I had to follow the directions carefully. I downloaded a zipped install and pasted into my local WAMP folder. Logged into GIT Bash and setup the SSH under my /c/wamp64/www/my_install/ folder.

    I had to download and setup the .gitignore file that allows for Wordpress Core changes because we've actually edited some of those files for object oriented programming.

    I then simply followed WPengine's protocol:

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

    I must have intially forgot to 'add . --all'.

    Setup my install to remote to my Staging:

    $ cd /c/wamp64/www/my_install
    $ git remote add staging [email protected]:staging/my_install.git
    

    I then deployed to my remote:

     $ git push staging master
    

    So far GIT is working until I screw it up next time.