How to make the link to the git output link read-only?

How can I tell git that although I want to enable git fetch on some branches, I don’t want to allow git push on these branches.

In other words, I have some branches that reflect the "current work", and I want to push them to my upstream repository. But I have other branches (including the master) that I intend to reflect "other work" in the context of the local repository, and I do not want to backtrack from these branches from here.

This is my remote repository, and in other contexts I want to be able to push all its branches. But not from this particular local instance.

I think this is possible because git remote show origin sometimes told me that I have branches configured for "git pull", but not for "git push". But I don’t understand the configuration files enough to create this effect manually, and I don’t understand the git command line language well enough to do it there.

Currently, I can best make sure that my local copy is outdated for upstream branches that I want to stay intact. (Also, by explicitly indicating the receiving branch on my command line, git push - indicating that I only want to paste into the remote instance corresponding to the branches of the locally checked branch - prevents clicking on unwanted branches. But I would like to eliminate this complication.)

+7
source share
2 answers

As in the case of Borealid, indicated in the comments, in your local copy you should install git config push.default upstream , and then additionally make sure that those branches that you do not want to use so as not to have an upstream branch assigned git branch --set-upstream command, but this will not allow you to set an empty upstream configuration to remove it, so you will have to manually edit the .git / config file and remove the line merge = refs/heads/* from the sections of the corresponding branches.

0
source

Actually, it looks like push.default = current will do what I want.

This is not exactly what I requested, but it is "good enough." And it has the advantage of being simple.

Simplicity - it is a virtue - simplifies the understanding and use of the system.

It also accurately mimics the behavior that I think I see from git pull.

0
source

All Articles