github repo deleted. Now cloning local to a new remote repo
My current git repo has all the commits and branches and whatever that was done in the repo. Although the remote repo somehow got deleted long back. I now want to push the current repo to a new remote as it is. I created this repo to learn git so I made sure that all the commits and branches are also present in the remote back then. Now I wanna do it again.
I am trying to understand reflogs of the repo so that I can compare what will go and what will not. Here are the reflogs below. I am stuck at the point that in the 3rd line, there's a branch name mentioned for the commit but only for the remote and not local branch. Can anyone clarify why is that?
If you could connect with me and see it live. It would help more in this case.
42 Replies
⌛
This post has been reserved for your question.
Hey @theash2473! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
ok so the reflog is a history of what happened locally
so it tells you what changed/what you checked out/commit on your device
For pushing all your local branches to a remote repo, you normally don't need the reflog
if you run
git push --all YOUR_REMOTE_HERE
, it pushes all branches you have locally to the remote you specifiedBut will it have each and everything as it was before. The commits, branches, merges etc?
depends did you pull all commits, branches, merges etc?
It will have everything that you have
See I was the only one in this repo. It was just a repo I created totest the tricks of git. So I have everything of it in my local.
then you are good
issues and PRs won't be included
if you want tags, you can push them with
git push --tags
What's that? I didn't create any tags before you ask.
tags are similar to branches
if you don't have any tags, you don't need to worry about it
ok
So you are able to understand the history of the repo from this log right?
I'm gonna attempt what you said. How would I check if everything happened correctly?
only a part of it
it's the history of what you did on that computer when that repo was checked out and typically only the latest things
if you tell git to commit something or switch a branch, it's added to the reflog but entries from there will be cleaned up at some point
Yeah it says 30 days but I have these logs even after 2 years somehow.
yeah it isn't instantly deleted
like if you don't do anything with the repo, it isn't deleted
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
No, the reflog. It is supposed to be deleted.
IDK
it gets cleaned up when running certain git commands IIRC
When common porcelain operations that create objects are run, they will check whether the repository has grown substantially since the last maintenance, and if so runhttps://git-scm.com/docs/git-gc that's what removes reflog entries except you remove it manuallygit gc
automatically. Seegc.auto
below for how to disable this behavior.
Atlassian
Git Reflog Configuration | Atlassian Git Tutorial
Reflogs track Git refs updated in the local repository. In addition, branch tip reflogs, a special reflog is maintained for the Git stash. Learn more.
Check this link
Twas 90 days not 30.
Did you manually run
git reflog expire
?No never
Just read this thing
then you shouldn't be surprised by these entries not being removed
.
git normally doesn't trigger it randomly if you aren't doing anything
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
Check this out.
https://stackoverflow.com/a/72284434/10841645
Stack Overflow
Connect a local repository with a remote repository
I have a local repository. I created the whole application, but now I want to push it to a remote repository. I already have remote repo as well. How can I connect these two repositories without lo...
It suggests to use set-url instead.
Will any of the two commands work?
git remote add
--> adds a new remote, you'd need to push with the remote you added there, you cannot use this if the remote exists already
git remote set-url
--> updates an existing remote, you'd need to push to the updated remote, you can only use set-url if the remote existsWhat is the use of git branch -M origin if I don't wanna change the names of any branches?
What?
Do you have a branch named
origin
? Why?No I don't have any but why do I need to change it?
Shouldn't I just upload the repo as is?
Also, why does it say in the documentation that -M moves/renames a branch? What does it mean by moving a branch? attaching it to another branch?
you said something about
git branch -M origin
which doesn't make senseohk
ignore origin. Just talking about the command in a new github repo
git branch -M main
I have no idea what you are trying to do
go to folder 📂
git init
git remote add origin < new repo url >
then commit -> then push
no need of renaming right?
idk why you would want that or where you have picked that up
In the page of a new repository it suggests that command before pushing.
On GitHub

you don't need that unless you want to change branch names
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
What is git remote add --mirror ? What does mirror do exactly?
When a fetch mirror is created with --mirror=fetch, the refs will not be stored in the refs/remotes/ namespace, but rather everything in refs/ on the remote will be directly mirrored into refs/ in the local repository. This option only makes sense in bare repositories, because a fetch would overwrite any local commits. When a push mirror is created with --mirror=push, then git push will always behave as if --mirror was passed.
I think I can ignore them then
I haven't looked into bare repositories
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.