Git: Undo local changes; git add . + git rm?

后端 未结 2 673

Need help figuring out a couple common workflows with Github. I come from a VS TFS background, so forgive me.

Undoing Pending Changes

Let\'s say

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-05 18:01

    How do I undo these local changes, restoring them to the current versions in the repository?`

    git reset --hard
    

    (this will reset your index and working directory to HEAD)

    Is there a git command that will git add . and git rm any files I've deleted locally, in one step?`

    git add -u
    

    (it wont add new files)

    If you want to add new files, remove rm'ed files, and stage modifications to files:

    git add -A
    

提交回复
热议问题