Push only last commit with TortoiseGit
I want to push only the last commit with TortoiseGit to a sourceforge repository. All previous ones shall not be pushed. Here is was said I can create a new branch and push this one. But the new branch has all previous commits and not only the last one.
What am I doing wrong?
One Solution collect form web for “Push only last commit with TortoiseGit”
I think this is primarily a misunderstanding of how git works. When you push a commit, if that commit has a parent, git will make sure that that parent is in the remote repository as well. Aside from sparse clones (which may be useful for preserving bandwidth and/or disk usage, but impose some restrictions on how you can interact with remote repositories), git is designed to keep the object database complete and consistent. Completeness/consistency would be violated if you could push a commit without it’s parents being in the repository as well. So, by design, you can’t just push one single commit without git making sure that commits lineage is preserved.
That said, there are two specific ways you can arrange to only push a single commit: 1) make sure that the parent of the commit you want to push is already in the remote database (e.g. use
rebase to squash all commits on the branch down to a single commit, and possibly relocate that branch if necessary – but that may not be the best choice for your workflow), or 2) make sure that the commit you want to push has no parents – e.g.
git checkout -b somebranch --orphan in recent versions of git, then create your commit.