Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
661 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...