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
805 views
in Technique[技术] by (71.8m points)

github - Automatically ignore selected code changes when pushing to a git-hub repository

In the types of coding projects that I work on, there is often a common code base that people use, and then build their own personalized code on top of it. A way to do this would be to keep the common base code in it's own git-hub repository, which people can then fork and modify.

However, when pushing changes to the common base code repository, you don't want to include your personalized code, so you have to be careful not to include it when merging. Is there a simple way to do this without having to tell git to ignore the personalized code every time?

If possible, I would prefer to avoid having a separate fork of the base code for the specific purpose of making changes to the base code.

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

If the personalization is limited to certain files, with a way to detect just be looking at its content, then you could:

  • version only template files, which would always be pushed to your "common content" repo
  • keep private value files (files with the right values in it, which are always ignored by your git repo and never pushed)
  • version script files able to take a template file, a value file, and generate the right valued end-result file automatically. That generated file wouldn't be pushed either, and would also be ignored by your git repo.

The idea is to make that generation automatically on checkout.
You do that by declaring a content filter driver.

content filter dirver

On checkout, in the smudge script, detect the content (those 'filter driver' scripts don't have the name of the files they are filtering) of a your template files, and generate the right content by looking for a value file in a specific path.


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

...