Git Unable to pull, not upload files

I have read all similar questions about this; It seems that none of the following worked:

Delete offending files git reset --hard HEAD git stash git pull 

Almost every combination that replaces changes and pulls from the repository leads to unflappable files. I would like to undo all local changes and just use remote access, but I cannot clone again (bandwidth and Internet usage restrictions with a developer trying to do this). How should I do it?

Just tried:

 git stash git pull 

Also did not work.

Additional Information

There is one local commit, and the upstream has a commit. I tried git pull --rebase this way, but it still doesn't work properly ... It gives me errors - "exit due to unresolved conflict". If I do git stash, git reset --hard HEAD, git pull --rebase , I get the error message: "pull is not possible, no change ..."

+71
git
Feb 28 '13 at 3:45
source share
8 answers

Let's say that the remote is origin and the master branch, and they say that you already have master , you can try the following:

 git fetch origin git reset --hard origin/master 

This basically just takes the current branch and points it to the HEAD remote branch.

WARNING As stated in the comments, this will discard your local changes and , rewriting everything at the beginning .. p>

Or you can use plumbing commands to do essentially the same thing:

 git fetch <remote> git update-ref refs/heads/<branch> $(git rev-parse <remote>/<branch>) git reset --hard 

EDIT: I would like to briefly explain why this works.

In the .git folder, you can save commits for any number of repositories. Because the commit hash is actually a validation method for the contents of the commit, and not just a randomly generated value, it is used to map sets of commits between repositories.

A branch is just a named pointer to a given hash. Here is an example:

 $ find .git/refs -type f .git/refs/tags/v3.8 .git/refs/heads/master .git/refs/remotes/origin/HEAD .git/refs/remotes/origin/master 

Each of these files contains a hash indicating a commit:

 $ cat .git/refs/remotes/origin/master d895cb1af15c04c522a25c79cc429076987c089b 

They are all intended for the internal git storage engine and work independently of the working directory. By doing the following:

 git reset --hard origin/master 

git will point to the current branch with the same hash value that the start / master points to. Then it forcibly changes the working directory according to the file structure / contents in this hash.

To see this at work, try the following:

 git checkout -b test-branch # see current commit and diff by the following git show HEAD # now point to another location git reset --hard <remote>/<branch> # see the changes again git show HEAD 
+162
Feb 28 '13 at 6:51
source share

I got lucky with

 git checkout -f <branch> 

in a similar situation.

http://www.kernel.org/pub//software/scm/git/docs/git-checkout.html

Cancel uninstall in git

+4
Feb 28 '13 at 3:52
source share

Solved using the following set of commands:

 git reset --hard git pull --rebase git rebase --skip git pull 

The trick is to reinstall the changes ... We had problems reloading one trivial commit, so we just skipped it with git rebase -skip (after copying the files).

+3
Feb 28 '13 at 4:24
source share

Assuming you want to discard all the changes you have, first check the output of git status . For any file that says "unmerged" next to it, run git add <unmerged file> . Then do git reset --hard . This will allow git to get rid of any local changes except files without a trace.

+1
Feb 28 '13 at 3:58
source share

I decided that using git delete the unloaded file locally.

 $ git rm <the unmerged file name> $ git reset --hard $ git pull --rebase $ git rebase --skip $ git pull Already up-to-date. 

When I submit git commit afterward:

 $ git commit . -m "my send commit" On branch master Your branch is up-to-date with 'origin/master'. nothing to commit, working directory clean 
+1
Jun 01 '16 at 5:55
source share

Ryan Stewart's answer was almost there. In the case where you actually do not want to delete local changes, there is a workflow that you can use to merge:

  • Run git status . It will provide you with a list of unrelated files.
  • Combine them (manually, etc.).
  • Run git commit

Git will only forward merges to the new commit. (In my case, I had added additional files on disk that were not focused on this commit.)

Git is then considered a successful merger and allows you to move forward.

0
Dec 04 '17 at 17:43 on
source share

If you ever manage to get this problem after running git fetch and then git does not allow you to run git pull due to a merge conflict (both modified / unmarked files and make you more upset, it will not show you any conflict markers in file, as it has not yet been merged). If you do not want to lose your job, you can do the following.

complete the file step.

 $ git add filename 

then record the local changes.

 $ git stash 

pull out and update the working directory

 $ git pull 

restore the local modified file (git will merge automatically if possible, otherwise allow it)

 $ git stash pop 

Hope this helps.

0
Dec 18 '17 at 10:25
source share

There is a solution, even if you do not want to delete your local changes. Just fix unsent files (using git add or git remove ). Then do a git pull .

0
Dec 10 '18 at 22:17
source share



All Articles