Synchronizing a local Git repository with a remote one

后端 未结 10 556
独厮守ぢ
独厮守ぢ 2020-11-30 16:00

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

10条回答
  •  被撕碎了的回忆
    2020-11-30 16:53

    Reset and sync local repository with remote branch

    The command: 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
    

    Or step-by-step:

    git fetch origin
    git reset --hard origin/master
    git clean -f -d
    

    Your local branch is now an exact copy (commits and all) of the remote branch.

    Command output:

    Here is an example of running the command on a local clone of the Forge a git repository.

    sharkbook:forge lbaxter$ git fetch origin && git reset --hard origin/master && git clean -f -d
    HEAD is now at 356cd85 FORGE-680
    Removing forge-example-plugin/
    Removing plugin-container-api/
    Removing plugin-container/
    Removing shell/.forge_settings
    sharkbook:forge lbaxter$
    

提交回复
热议问题