Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
213 views
in Technique[技术] by (71.8m points)

git extensions - Git: push different files to various remotes

I am using git extensions. I do have various branches and I have got set already various remotes. There is over 10k files in repository. Now I need to push only a few specific files to one from those remotes (bitbucket). Those specific files will be pushed regularly. What would be the best work flow for this?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Git does not push files. Git pushes commits. Now, it's true that commits contain files. But it's a package deal: think of commits like a truck full of furniture. You can't just deliver one end-table or chair. The entire truck has to go somewhere. (Don't push too hard on this analogy or it will fall apart. ??)

To push a given commit to some remote by name, run:

git push <remote-name> <commit-specifier>:<name>

The commit-specifier part on your side can be a branch name, a tag name, a raw commit hash, or whatever. The remote-name can be any of your remote names. The name part, on the right side of the colon, is the name in the remote, by which anyone using that other Git repository—over on the remote—will find the commit you sent using the commit-specifier on your side to pick a commit.

Because commits are history, sending a commit will automatically send all earlier commits, if that remote does not have them. They will get every commit up to and including that one. If the remote does already have them—which is pretty common—they won't need those commits.

The Git protocols enable two Gits to talk to each other and find out which commits they have. When the receiving Git says I have commit a123456 to the sending Git, that notifies the sending Git that the receiver not only has that commit, but all the commits leading up to and including that commit, because commits are history and we always1 send all the commits needed for a complete history.

The sending Git will see that the receiving Git not only has all those commits, but also all the files that are in that commit. So the sender can compress any commits he is sending by entirely omitting any files that match, and by compressing new files down to delta-encoded instructions telling the receiver how to build those files from the files he already has. These compressed instructions work very well for plain text files. They tend to work poorly for pre-compressed binary files, such as jpeg images.


1The exception to this rule is shallow repositories, which make things complicated. One makes these with git clone --depth. (The receiving repositories on Bitbucket won't be shallow repositories.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...