Git force complete sync to master

My workplace uses Subversion for source control so I have been playing around with gitsvn for the advantages of my own branches, commit as often as I want without touching the main repo, etc.

Since my git svn checkout is local, I have cloned it to a network share as well to act as a backup. My thinking is that if my desktop takes a dump I will at least have the repo on the network share to get changes that I have not had a chance to dcommit yet.

  • Can't import android project from git
  • Problems with certain git repos in GitKraken and Atom, causing Atom to be unusable
  • p4 command line equivalent to “git log -p”?
  • Move branch to another branch
  • Safety of using Git's filter-branch to rewrite if only modifications are to commits which haven't been pushed yet?
  • How to conditionally skip maven tests on Jenkins for CI
  • My workflow is to work from the desktop, make changes, commit, etc. At the end of the day I want to update the repo on the network share with all of my current changes. I had setup the repo on the network share using git clone repo_on_my_desktop and then updating the repo on the network share with git pull origin master. The problem that I am running into is when I used do a git rebase to squish multiple commits prior to dcommitting to the main svn repository. When I do this, I get merge conflicts on the repo on the network share when I try to backup at night.

    Is there a way to simply sync entirely with the repository on my desktop without doing a new git clone each night?

  • How do you undo changes committed to main line from a feature branch but keep the branch up to date?
  • git clean -d -f removes directories containing files which are ignored. Can I keep the ignored files and still run git clean -d
  • Git GUI like Bzr Explorer but for Git?
  • Git workflow (Dev>Staging>Live) basic technical questions
  • Github workflow and pull requests showing unwanted commits
  • TFS 2013.4 build with GIT submodules are failing
  • 2 Solutions collect form web for “Git force complete sync to master”

    Two comments:

    1/ I would recommend having either bare repo or a bundle (one file, easier to move around) for your network share

    2/ I would rather add network_repo as a remote to your desktop repo and push from there (git push --force network_repo master): you stay in your working repo.

    You shouldn’t be doing a rebase if you intend to pull from another repo.

    If you don’t mind overriding changes in your network share, you can do this:

    git fetch origin master
    git reset --hard origin/master
    

    This will reset the local master to the origin master.

    Warning: this is a hard reset, it will lose all your changes (committed* or not).

    But I’m assuming you don’t really have any changes there, and it’s mostly just a backup.

    * Note: technically speaking, committed changes are not lost until they expire from the reflog, but for all intents and purposes, they’re effectively lost.

    Git Baby is a git and github fan, let's start git clone.