J
J
jony7212021-11-25 07:11:35
git
jony721, 2021-11-25 07:11:35

How to synchronize a project with a remote repository?

1. There is a project on a remote repository.
2. It is also available on the server. I don't have it.
3. I downloaded it from the server.
4. My task: Check if there are any changes on the project downloaded from the server that are not on the remote repository. If yes, then commit and push them to the remote repository.

I did
git init
git remote add origin ....

What's next?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Kuznetsov, 2021-11-25
@jony721

Oh, these translation difficulties)) remote is usually translated into Russian as remote. But what if I want to remove the remote? Delete remote?
Therefore, it is better to say "external" so as not to be confused. We are working with a local repository, and all others will be external to it. There is no centralization in Git, all repositories are equal and can exchange information in arbitrary directions.
So: we have two external repositories and want to synchronize them? No problem.
You can use the local computer as an auxiliary.

I did
git init
git remote add origin ....

The beginning is illogical. Are you saying that you have already downloaded the repository from the server?
i.e. done git clone <server1>
This has already created a copy of the repository and init is not needed. It also automatically created an origin link too.
Then you can change the origin address to the second server
git remote set-url origin <server2>
. And we will immediately see if there are any differences in git status.
Although no, I'm lying. It is necessary, after changing the address, to download the external branches again with the command
git fetch
. Only then will there be something to compare.
More or less like this. This is the first thing that came to mind and perhaps rude. You can come up with a more accurate scheme.
I would rather not delete the old remote, but add a new one. Let the fact that you "downloaded from the server" remain as origin. Let's denote the "remote" repository as upstream
git remote add upstream <server2>
git fetch upstream

Then we can compare any branches and synchronize.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question