Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»GIT»How to Force Overwrite Local Files on Git Pull

    How to Force Overwrite Local Files on Git Pull

    RahulBy RahulNovember 30, 20151 Min Read

    Using Git pull, we download latest changes from Git remote repository to local repository code. During this process, we faced issues many times due to local changes. Then we need to force overwrite any local changes and update all files from remote repository.

    Important :-

    • All the local changes will be lost.
    • Any local commits that haven’t been pushed will be lost.
    • Any files that are not tracked by Git will not be affected.

    Commands to Overwrite Local Files:-

    Use the following command to force overwrite local files from remote repository. We are assuming you are downloading changes from remote master branch.

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

    To download changes from some other branch use the following command.

    $ git reset --hard origin/other_branch
    

    Explanation:-

    • Git fetch command downloads the latest updates from remote, but don’t merge or rebase in local files.
    • Git reset resets the master branch to what you just fetched. The –hard option changes all the files in your working tree same as on origin/master
    git
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Install Mean.io On Ubuntu, Debian & LinuxMint
    Next Article How to Setup vnStat (Network Traffic Monitor) on Ubuntu / Debian / LinuxMint

    Related Posts

    How To Add a Git Remote Repository

    3 Mins Read

    How to Git Reset to Head

    Updated:November 3, 20213 Mins Read

    How to Delete a File on Git

    3 Mins Read

    How to Git Stash Changes

    Updated:October 29, 20213 Mins Read

    How to delete Git tags

    Updated:October 25, 20211 Min Read

    How to Create Git tags

    Updated:October 25, 20212 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    • (Resolved) Please install all available updates for your release before upgrading
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.