I have a repo in sync with google Drive, but I had the .git directory ignored so it is now uploaded to Google Drive.
Recently I formatted my Gentoo
machine and after I had all Google Drive files synced again I realized the .git
directory was not there.
The problem is I do not remember if I had some unstagged/uncommited changes in local not pushed to github.
I have been searching but I only found answers for the opposite question (Cloning without the .git
directory)
I do not want to make a git clone
of my repo until I am sure that possible local changes are not going to be loss.
Is there any way of cloning only the .git
folder and then push any local changes that I may have in my machine?
The one-step solution would be:
git clone --no-checkout <repo_url>
or if you already have an empty dir for it,
cd myrepo
git clone --no-checkout <repo_url> .
Basically what you want is a fresh .git
directory without any changes to files, so you can do git status
and see if anything was changed.
Expecting your pwd
is your project directory with an old .git
directory that has the origin
for the repository set up, you could run the following command:
mkdir -p /var/www/tmp/_delme \
&& git clone --no-checkout `cat .git/config | grep url | awk -F' = ' '{print $2}'` /var/www/tmp/_delme \
&& rm -rf .git \
&& mv /var/www/tmp/_delme/.git . \
&& git add -A
&& rm -rf /var/www/tmp/_delme
git clone
to a different folder on your machine from your online repoIf 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