Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
+1 vote
39 views
in Information Technology by (176k points)
What is the impact of git reset on the remote repository?

Please log in or register to answer this question.

1 Answer

+1 vote
by (176k points)

git reset affects only the local repository. It does not automatically affect the remote repository. If you have pushed commits to a remote repository and then use git reset, you will need to force push (git push --force) to update the remote branch, which can rewrite history and potentially disrupt collaborators.

Example Code

  1. Reset to a previous commit and keep changes staged:

    git reset --soft HEAD~2 

    This will move the HEAD to two commits ago and keep changes staged.

  2. Unstage all files and keep changes:

    git reset 

    This will unstage all changes but leave them in the working directory.

  3. Discard all local changes and reset to the latest commit:

    git reset --hard HEAD 

    This will reset the working directory and the staging area to the latest commit, discarding all local changes.

  4. Undo a commit but keep changes in the working directory:

    git reset --mixed HEAD~1 

    This will undo the last commit and unstage the changes, leaving them in the working directory.

Related questions

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...