I
I
Ivan Antonov2019-11-02 10:38:07
git
Ivan Antonov, 2019-11-02 10:38:07

How to bring a local git repository in line with a remote one?

On my computer, I screwed up a little with branching. Created several unnecessary branches. Moved master. And generally lost in the branches. Tell me how to return the local working directory and all branches to the form that is now in the remote repository?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ivan Antonov, 2019-11-02
@antonowano

Made a clone to a neighboring directory
Deleted a folder .gitfrom the working directory
Moved .gitfrom a newly created clone
Made a reset in the working directory

cd public_html/
git reset --hard

Removed temporary clone
cd ../
rm -rf public_html2

A
Andrey, 2019-11-02
@VladimirAndreev

If there are no necessary edits of local branches -
git checkout branch_name
git reset --hard origin/branch_name
If there is - create a folder nearby, raise git there
Add it as a second origin and push the necessary branches into it.
Go back to option 1
Then sever edits and remove the second turnip.

D
Dmitry, 2019-11-07
@dlnsk

It's enough just to create a temporary branch at the end of the one you are going to fix

git checkout branch_name
git checkout -b temp

After that, you can do branch_namewhatever you want with it. tempwon't let the commits go to waste. Well, then git cherry-pickeverything that is needed in the corrected branch or in any other.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question