I know similar issues have been addressed in a bunch posts, but I couldn't figure out how to solve this issue anyway.
So, I have synchronized my local directory with this git repo
Dario (master *) replicationKumar $ git remote -v
origin [email protected]:DarioBoh/replicationKumar.git (fetch)
origin [email protected]:DarioBoh/replicationKumar.git (push)
I successfully pushed a few commits, so I am pretty confident I have synchronized everything correctly. Also, I ran
Dario (master *) replicationKumar $ git pull origin master
From github.com:DarioBoh/replicationKumar
* branch master -> FETCH_HEAD
Already up-to-date.
which shows that I should be working on a copy of what I have on github. Since the last commit, I deleted a few files though, and now I would like to recover all them from the remote directory from this commit
Dario (master *) replicationKumar $ git log
commit 91a3dfdb30084654a7a5517250d2a70dfddb931b
Author: DarioBoh <[email protected]>
Date: Tue Jul 19 10:00:12 2016 -0500
REFACTOR linechart moved from server to chart.R
In fact, the local directory currently looks like this
Dario (master *) replicationKumar $ ls -a
. .RData .Rproj.user .gitignore
.. .Rhistory .git replicationKumar.Rproj
I thought checkout
was gonna do the job and I did
Dario (master *) replicationKumar $ git checkout 91a3dfdb30084654a7a5517250d2a70dfddb931b
D charts.R
D datasets.R
D server.R
D sidebarMenu.R
D ui.R
D ui1.R
D ui2.R
Note: checking out '91a3dfdb30084654a7a5517250d2a70dfddb931b'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at 91a3dfd... REFACTOR linechart moved from server to chart.R
However, my local directory does not show the files present in the checked out commit as I would expect
Dario ((91a3dfd...) *) replicationKumar $ ls -a
. .Rhistory .gitignore
.. .Rproj.user FETCH_HEAD
.RData .git replicationKumar.Rproj
If you wish to only revert those files, and to do so on the master branch, then you should:
This will look something like the following:
git checkout master
git checkout [commit hash] [path/to/file.txt]
...
git add .
git status (does everything look right?)
git commit
This will add a new commit to master which reverts the files to their state from the specified old commit. Afterwards you will probably want to run another git push
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With