After resetting my laptop, I just had the code backup. unfortunately
.git folder got removed while copying data. Cloning the repository again sounded bad for me due to its size and the poor intermittent network connectivity. Cloning of the repository failed multiple times. This might be a situation you might be undergoing. Here is the way I did to clone the repository to existing directory with all the remote data.
This can be done for:
- Linking the local directory with data and remote git repository WITH data
- Linking the local directory with data and remote git repository WITHOUT data
Step 1: In the terminal, navigated to the appropriate directory where I had my data.
Step 2: Init the repository again, since I lost
Step 3: Committed the directory
git add . git commit -m 'cloning again'
Step 4: Added remote origin
git remote add origin https://<url_here>.git
Step 5: Pulled the remote origin
git pull origin master --allow-unrelated-histories
Step 6: Pushed the local changes to remote
git push -u origin master
Tada! I got my repository back to my previous state!!