Reputation: 184
I need to apply a patch but:
git pull
and then execute the script for my patch. I must apply the patch and then apply my fixes to that patch.git pull
once the patch is applied (Your local changes to the following files would be overwritten by merge)Usually I would :
git -fetch
git reset --hard
The problem is the git -fetch
has no effect:
git log | head
and
git log origin | head
have the same output, though the origin repository is 4 commits ahead (and git knows that when I do a git status
).
What I'm trying to do (TL;DR):
I would like to fetch my last commits from the remote repository so that I can do a hard reset after.
Upvotes: 1
Views: 134
Reputation: 184
My mistakes were actually quite simple. The right command to display the log was:
git log origin/branchname
I was then confirmed that the git fetch
worked fine.
Then I did:
git reset origin/branchname --hard
It worked a lot better.
A simple git reset
would just set the code to the last local commit, when I wanted the last remote one.
Upvotes: 1
Reputation: 1
I suggest to give more data, and show clear commands and error messages. To your question people can give you only a conceptional answer, which may or may not be enough for you.
What should surely work:
git reset
.git pull
.git add .
, git commit -m blah
, git push
commands.It will surely okay, although you will have an intermediate state where the merge is already applied, but the code isn't working. On my opinion, it is not a problem - at least, not on a development branch. If you need to do everything in a single, unified commit, you can play with cherry-pick and rebase (first I like much better, but others like rebase).
If you did rebase as well, it can make things much more problematic, although it is matter of opinion (I am highly against rebase, but others have different opinion).
Upvotes: 1