lobiinspired.blogg.se

Git discard local changes
Git discard local changes









You can verify by opening the file in VIM or any other editor. Git status, again, shows nothing changes. Nothing to commit (working directory myrepository]# vim firstFile.c In your case the command would be: git checkout HEAD. myrepository]# git checkout myrepository]# git status In your checked out directory execute this command which will reset the files changed in that sub-directory to HEAD revision (in short it will discard your uncommitted changes in that submodule/subdirectory) git checkout HEAD - path/to/submodule. If the file has unwanted changes, the following will discard the changes. No changes added to commit (use "git add" and/or "git commit myrepository]# " to discard changes in working directory)

git discard local changes

#Git discard local changes code#

Now we will add some unwanted code in firstFile.c. And it should be, as nothing changed yet. Git status shows there are no changes in any file. Nothing to commit (working directory myrepository]# rw-r-r- 1 root root 0 Dec 23 03:04 myrepository]#

git discard local changes

For instance, if we realize that we forgot. rw-r-r- 1 root root 0 Dec 23 03:04 secondFile.c The -soft aims to change the HEAD (where the last commit is in your local machine) reference to a specific commit. Receiving objects: 100% (5/5), 454 bytes, gitundochanges]# ls -lrtĭrwxr-xr-x 3 root root 4096 Dec 23 03:04 gitundochanges]# cd myrepository]# ls -lrt Remote: Total 5 (delta 0), reused 0 (delta 0) Remote: Compressing objects: 100% (3/3), done. gitundochanges]# git clone empty Git repository in password: When we do not want to stage unwanted changes, we need to discard changes so that in the next commit, the unwanted changes will not go into the local repository.Ĭlone the repository to bring the files to the local machine from the remote.









Git discard local changes