I've been working on my local repository and pushing to the git server several times while the server I deploy my work on is still behind all those commits.
Shortly, the situation is like this:
local: commit n+5
git server: commit n+5
dev server: commit n
Now I want to pull only the commit number n+5 to the dev server (without including the commits n+1, n+2, n+3 and n+4).
I googled and found some solutions, including this one on Stackoverflow.
I tried git reset --hard <commit>
but it didn't work, I got this error:
git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
git reset --hard 77de3a5
fatal: ambiguous argument '77de3a5': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
I wanted to try the other proposed solution (using git fetch
and git merge
) but I got confused when it was said
Note: git merge will get all the changes in and its ancestry, so this works if is the oldest non-merged commit.
I am afraid that this approach would include (pull/merge) all the commits that are before the commit n+5.
Is there any way to pull just one commit (without including the previous commits)?
PS: I know the cleanest way is to use different branches, but what to do when you get a bit messy!