Ignore specific files when extracting from a forked upstream source

In git, how do you free certain files when you extract from the original source (i.e. the original project)?

I have a project that I'm working on that was originally forked from a repository that is very active. I added the original as deleted with the name "upstream" so that it can start:

git pull upstream

and update the project to the last commit.

Problem: There are some files (e.g. my Gruntfile.js) that I do not want to update next to the original project. Whenever I pulled these commits, I got merge conflicts because I changed the files in my own version.

I want to track these files for my local commits and fetch changes from my own source, so adding them in .gitignoreon an ongoing basis is not an option.

My current solution is to temporarily complete the grunt task: add Gruntfile.jsand others to .gitignore, pull from the upstream, and then remove them from .gitignoreso that I can track my own changes and click on its start. However, it feels hacked.

Is there a way to ignore these files only when outputting from "upstream"?

+4
source share
2 answers

Yes you can do it.

git pull is short for git fetch followed by git merge FETCH_HEAD

, ,

git fetch upstream

git merge --no-log --no-ff --no-commit upstream/branch

git . , .

UPDATE

git.

~/.gitconfig

[alias]
   fnm = !git fetch upstream && git merge --no-log --no-ff --no-commit upstream/branch

,

[alias]
   fnm = !git fetch upstream && git merge --no-log --no-ff --no-commit upstream/branch && git reset file/path/not/to/be/updated && git checkout file/path/not/to/be/updated

git fnm .

+7

,

. , , ?

(, URL-), , ?

, , https://github.com/fabelier/Doorbell: config.js.template, , config.js, ; Git.

0

All Articles