Back

Explore Courses Blog Tutorials Interview Questions
+4 votes
2 views
in DevOps and Agile by (19.7k points)

I want to synchronize my local repository with a remote one so that my local repository becomes a 100% copy of the remote one - meaning that if certain files differ in these repositories, we override the local ones with the remote ones, and if there are files in local repositories that do not exist in the remote, the local files get removed.

Is there any way to achieve that other than by doing a fresh clone of the remote repository?

closed

1 Answer

+5 votes
by (62.9k points)
selected by
 
Best answer

Here is a simple way to sync your local copy with remote content. Here is how (#with explanation). While in your working branch:

git fetch # This updates 'remote' portion of the local repo.

git reset --hard origin/

# this will sync your local copy with remote repository content, discarding any committed

# or uncommitted changes.

Although your local commits and changes will disappear from sight after this, it's possible to recover committed changes, if necessary.

Browse Categories

...