Note that there are some explanatory texts on larger screens.

plurals
  1. POUndo git pull from remote branch on a fresh git repository to a state before git pull
    primarykey
    data
    text
    <p><em>In short:</em></p> <p>Can I reset my code to a state before I do a <code>git pull</code> after pulling code from remote branch on a <strong>fresh git repository</strong>?</p> <p><em>Long story:</em></p> <p>I have two folders containing scripts, one folder represent another version of files inside the other folder. To apply version control, I start by creating a git repository in github with folder that has less revision compared to other folder, and create two branch with the same content to represent both folder.</p> <p>To synchronize folder that has the latest revision to the remote branch, I do the following in that folder:</p> <pre><code>git init git remote add origin [GITHUB_REPO] git pull origin [BRANCH_NAME]:[BRANCH_NAME] git add . git commit -m "Latest revision." </code></pre> <p>I have tested the workflow several times before and there seems like nothing's wrong until I later on realize that right before <code>git add .</code> I run <code>git status</code> and no modification is shown, it only shows new untracked files, which is weird.</p> <p>I need to undo to a state before I do <code>git pull</code>, because I realized that some of my files gets overwritten with remote, but since <code>pull</code> is the first action, and no commit before that, I can't reset to anything before <code>pull</code>.</p> <p>This is the result of <code>git reflog show</code>:</p> <pre><code>edbfd0d HEAD@{0}: commit: Import code from development environment. da39602 HEAD@{1}: checkout: moving from master to development </code></pre> <p>What I have done is:</p> <pre><code>git reset HEAD@{1} </code></pre> <p>And this doesn't solve the problem, it only undo the last commit, and overwritten files from <code>git pull</code> still doesn't come back. If it helps, the version of git on the server is 1.7.1, and on my local machine is 1.8.2.1. No wonder they act differently.</p> <p>--</p> <p>After further research, I found that the behavior of <code>git pull</code> in the server is different from my local development machine. It seems like in the server <code>git pull</code> automatically merge, while in my local development tells me there are files that might be overwritten on merge.</p> <p>This causes files in the server automatically uses the less revised version on <code>git pull</code> on existing file with untracked files, while in my local development I can add the modified file and use the updated version.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload