Have tried the accepted answer on this page here: How to merge the current branch into another branch
But the problem is, the master doesn't have any changes needed, and I created the branch with: git checkout -b mybranch
When I try git push self mybranch:master
It tells me that Everything up-to-date. But I know that. I just want to copy branch to another so that it has the current state of the master branch. And it will not ever be touched again.
I will only be branching off of the master branch in the future. This other branch will never actually be touched. But I need to archive it so that if need-be, I can switch to that branch and bring it back whenever...
How to copy master branch without creating a New Repo?
As noted in the answer by Zoli Szabo, you should use tags to mark events in history which should never move. To create a tag, simply provide its name and the commit it should point to. If you provide a branch name instead of a commit hash, the tag will point to the current tip commit of this branch.
git tag mytag branch
git tag mytag 123ab45ef
But to answer your question, if you want your branch to reflect the current state of master, you have a handful of options:
git branch -f mybranch master, then pushing the branchgit push origin master:mybranch (-f if you need a force update). Careful, as this might cause problems to other peopleours strategy (-s ours), to create a new commit with the wanted state. Then pushing to the remote repository.If you simply want to update your local repository, either merge the branches (should result in a fast-forward, if I've understood your question correctly), or do a local push.
git checkout master; git merge mybranchgit push . mybranch:masterA push is kind of the reverse of a fast-forward merge (target and destination branches switched).
Take your pick :)
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