I got a git repo on bitbucket that was used a few months ago for a php application.
I now have a new server and I would like to connect the local folder of this app on that repository. Challenge for me is that the local version is now more up to date than the bitbucket version. I'm newbie on git, and instructions I find always imply that we first clone the repo. I do not want to overwrite the local files first.
You need to clone the whole repository for this to work. Git needs to know about all the files and . git to do its job correctly. This is why you can't just push arbitrary files like that.
When you clone a repository with git clone , it automatically creates a remote connection called origin pointing back to the cloned repository. This is useful for developers creating a local copy of a central repository, since it provides an easy way to pull upstream changes or publish local commits.
Without any Git init or clone you can do this:
git ls-remote [url]
Here is your output:
5fe978a5381f1fbad26a80e682ddd2a401966740 refs/heads/master
d6602ec5194c87b0fc87103ca4d67251c76f233a refs/tags/v0.99
see more here Git Documentation git ls-remote
Instead of:
git clone {remote-url} .
If you don't already have a repo in the directory you're working in then this approach will work:
git init
git remote add origin {remote-url}
If you do already have a repo in the directory you're working in:
git remote update origin {remote-url}
Now you have a repository that has been cloned, but is connected to your remote origin.
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