0

I am new to the world of grunt but I feel like there must be a way to do this. Hopefully I can explain my issue in a way that makes sense so you can be of assistance.

Essentially, I have a git project, including a gruntfile, that I use to start all new websites. I clone the project, delete the .git folder and setup a new project in bitbucket for it. Over time I have had to make some modifications to the gruntfile and it is annoying to go back to an old project where I hadn't made those modifications. Is there a recommended way to ensure that my template is up to date on all of my projects?

Things to note:

1) I am familiar with grunt scaffolding but I have never used it, is this the use case for it?

2) my projects live in bitbucket and are private. My initial solution to this problem was to use grunt curl and pull the latest and overwrite the previous gruntfile

3) The issue with #2 is that I would need to put my username/password in the path and can't figure out how to prompt the user, even if I do and they enter the login incorrectly bitbucket still returns something (a bad login page) and this would overwrite my gruntfile.

Thanks in advance! I appreciate anyones input

raydeneg
  • 35
  • 3

1 Answers1

0

I assume you are using git with bitbucket. If that is the case you can do a pull from a master repo that contains your template grunt file in each of your project repositories for the desired effect.

See this answer for how to pull from a remote repo.

remote repo q

Since you only care about merging in changes from the Gruntfile.js you can pull it specifically from the remote template repo. I'd suggest following this pattern assuming you add the remote reference to you template repo when necessary:

  1. From you project repo create a new branch
  2. Pull the Gruntfile.js from the template repo
  3. Resolve any merge conflicts
  4. Merge with master

See the last answer on this question for how to pull a single file: fetch a single file

Community
  • 1
  • 1
Gordon Bockus
  • 860
  • 6
  • 11
  • Hey, thanks for the reply. This works but it pulls the entire original template which causes issues when merging. For example in the template I have default html/css that I edit on the individual sites. Now anytime I try to do a merge there will be conflicts on those files. Is there a way to say use the latest on all files but these two? Another options I am familiar with is git sparse but I don't know how to set it up for only a specific remote repo. – raydeneg Sep 23 '14 at 15:01
  • Yeah I'm not sure how to do a sparse for an alternate remote. The last answer here look promising http://stackoverflow.com/questions/16230838/git-is-it-possible-to-pull-just-for-one-file – Gordon Bockus Sep 23 '14 at 15:27
  • Thanks! This should work for my issue! git fetch $gitrepo git checkout FETCH_HEAD -- Gruntfile.js package.json – raydeneg Sep 23 '14 at 15:48
  • Gordon - I want to give you credit for the answer but your original answer isn't the one I ended up using. Can you edit or create a new answer so I can close this question? – raydeneg Sep 23 '14 at 17:01