I have this situation:
MacBook:Ja.git alan$ git status
On branch alan-1
Your branch is up to date with 'origin/alan-1'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: Ja/Views/CardsTab/Xaml/Actions/QuizActions.xaml
deleted: Ja/Views/CardsTab/Xaml/Actions/QuizActions.xaml.cs
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: Ja/App/SetResourceColors.cs
modified: Ja/App/Styles.cs
modified: Ja/Templates/Button/Button.xaml.cs
modified: Ja/Views/CardsTab/CardsTab.xaml
modified: Ja/Views/CardsTab/Xaml/Actions/Actions.xaml
Is there a way that I can recover back these files that I just deleted. Not sure if this helps but the origin still has the latest version of those files.
You can start by following the prompt message and try:
git reset HEAD -- Ja/Views/CardsTab/Xaml/Actions/QuizActions.xaml
That should unstage the deletion and restore the file with:
git checkout -- Ja/Views/CardsTab/Xaml/Actions/QuizActions.xaml
As commented by torek, this could be done in one step:
git checkout HEAD -- Ja/Views/CardsTab/Xaml/Actions/QuizActions.xaml
If you haven't changed anything and you just want to update from remote origin branch you can do
git reset --hard HEAD
git pull
and you will be synced with remote origin
BEWARE though : all your local changes will be lost with reset --hard
If you need to save changes do
git stash
git pull
now check the files are on their place
and apply the stash if you need it
git stash pop
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.