Skip to content

Instantly share code, notes, and snippets.

@mikehins
Last active December 28, 2023 02:39
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mikehins/63ed06a467fb8eb2ea7c to your computer and use it in GitHub Desktop.
Save mikehins/63ed06a467fb8eb2ea7c to your computer and use it in GitHub Desktop.
git: sync local repo with remote one
http://stackoverflow.com/questions/6373277/git-sync-local-repo-with-remote-one
This makes your local repo exactly like your remote repo.
Remember to replace origin and master with the remote and branch that you want to synchronize with.
git fetch origin
git reset --hard origin/master
git clean -f -d
#GIT UNDO
------
$ git commit -m "Commit that needs undo" # (0)
------
$ git reset HEAD~ # (1)
[ edit files as necessary ] # (2)
$ git add . # (3)
$ git commit -c ORIG_HEAD # (4)
@BrianJerez
Copy link

thank you! :)

@aokasumi
Copy link

aokasumi commented Jul 9, 2018

Nice solution, thanks.

@technoakshat1
Copy link

thanks great solution to work on team like this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment