Having problem in Github and remote Git repo with production and development code

–1 vote

I am having my local Git repo which I am pushing and pulling to Github with my team as a central repository.

I am also having a remote staging area which has the whole bare repository and post-receive hook which pushes my changes to the web.I am using git push staging master for this which puts site to the staging area.

I don't want my dist/ stuff in the Github repo as this is causing many conflicts and doesn't need to be there, but I do want it in my remote website repo for production. How can I resolve this issue?

I've already tried setting up separate .gitignore files for each remote, but this doesn't make sense as it almost defeats the point of Git. Can anyone help me with this.

Apr 10, 2018 in Git & GitHub by Atul
• 10,240 points
1,150 views

1 answer to this question.

0 votes

I think you could start with this.

The thing you want is to always ignore the dist directory and make the server (staging or prod) trigger a npm install after it has checked out the latest version.

If you are using yarn or npm v5, commit the yarn.lock or package-lock.json file that it generates.

Then, make it trigger your gulp build with npm's post-install hook.

You can also go with using husky, a npm module which automatically installs itself in the .git directory, letting you define and version git hooks based on commands in the scripts attribute of the package.json.

"scripts": {
  "postcheckout": "npm install", // <-- Git hook from Husky
  "postinstall": "gulp build"    // <-- default npm hook
}
I hope it will resolve your query.
answered Apr 10, 2018 by shubham
• 7,340 points

edited Dec 15, 2023 by Khan Sarfaraz

Related Questions In Git & GitHub

0 votes
1 answer

How to create branch in GitHub from my local Git repo?

Hi@akhtar, To sync your existing branch in GitHub, ...READ MORE

answered May 7, 2020 in Git & GitHub by MD
• 95,460 points
908 views
0 votes
1 answer

Configure Git and GitHub

In version control with Git, we deal ...READ MORE

answered Apr 26, 2018 in Git & GitHub by DragonLord999
• 8,450 points
822 views
0 votes
1 answer

meaning of check-in code in github

It simply means to upload code to ...READ MORE

answered Apr 29, 2018 in Git & GitHub by ajs3033
• 7,300 points
10,839 views
0 votes
3 answers

difference between git remote and git clone

HI.... GIT REMOTE add just creates an entry in ...READ MORE

answered Jul 11, 2020 in Git & GitHub by anonymous
23,524 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,053 views
+2 votes
1 answer
0 votes
1 answer

Trying to analyse Sonarqube from Drone.io in Github PRs

Just try the below steps.The DRONE_PULL_REQUEST environment variable has ...READ MORE

answered Jun 27, 2018 in Git & GitHub by shubham
• 7,340 points
1,229 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP