ProfessorAmanda / econsimulations

This repository provides the code underlying simulations for teaching statistics and econometrics. The project site, which includes teaching materials as well as the link to the simulations, is located here: https://amandagreggeconomics.com/statistics-simulations-project/
Other
1 stars 0 forks source link

Git/npm Cheatsheet #136

Open ethansaxenian opened 3 years ago

ethansaxenian commented 3 years ago

Here is a list of useful commands to know:

To view the site on branch_name:

git checkout branch_name
git pull
npm start

If you get a module not found error:

npm install
npm start

To delete all outdated local branches:

git branch --merged | egrep -v "(^*|master|development)" | xargs git branch -d
tbyker commented 3 years ago

Thank you!!

Get Outlook for iOShttps://aka.ms/o0ukef


From: Ethan Saxenian @.> Sent: Friday, July 16, 2021 1:03:37 PM To: ProfessorAmanda/econsimulations @.> Cc: Byker, Tanya S. @.>; Assign @.> Subject: [ProfessorAmanda/econsimulations] Git/npm Cheatsheet (#136)

Here is a list of useful commands to know:

To view the site on branch_name:

git checkout branch_name git pull npm start

If you get a module not found error:

npm install npm start

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHubhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FProfessorAmanda%2Feconsimulations%2Fissues%2F136&data=04%7C01%7Ctbyker%40middlebury.edu%7C10419c58fa6b44a42f8608d9487ba7af%7Ca1bb0a191576421dbe93b3a7d4b6dcaa%7C1%7C0%7C637620518189496367%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=QDPoVYG2I%2BPfZbeqtoODeXFIDRJ9unKoPbOKFUX93BY%3D&reserved=0, or unsubscribehttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAP65VZ7O7ODV6AK45GRY4ZLTYBQ6TANCNFSM5AP5ZHVQ&data=04%7C01%7Ctbyker%40middlebury.edu%7C10419c58fa6b44a42f8608d9487ba7af%7Ca1bb0a191576421dbe93b3a7d4b6dcaa%7C1%7C0%7C637620518189506364%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=nzZ1xpOauPU9Whzswcb1CRD6jmVuivbS3fGnOtdmW%2Fk%3D&reserved=0.

ethansaxenian commented 3 years ago

@tbyker if you want to check out the 3d plot, it is on the branch named 3d-regression. You will most likely need to run npm install before npm start

tbyker commented 3 years ago

image

see screen shot ^^^^ which branch is beta distributions on? And I don't see the 3d-regression branch...

ethansaxenian commented 3 years ago

Beta distributions is on master.

You should still be able to run git checkout 3d-regression. Let me know if it doesn't work.

tbyker commented 3 years ago

Hi. I am trying to look at the master and getting this error: image

I did:

git checkout master git pull npm install npm start

ethansaxenian commented 3 years ago

Yikes, that's a bug, and it's also on the deployed website. I'll fix it and let's get it deployed quickly

tbyker commented 3 years ago

Maybe the bug affects all branches? I was trying to look at the 3-d stuff (using the 3d-regression brand) and after spinning a long time I got this... No rush if you are working on the other stuff.
image

image

ethansaxenian commented 3 years ago

The bug should now be fixed on the master branch! Just run git pull

ethansaxenian commented 3 years ago

Oh just saw that second bug, no idea what that is...

tbyker commented 3 years ago

should i just try again?


Tanya Byker

Associate Professor, Economics

Middlebury College @.**@.>



From: Ethan Saxenian @.> Sent: Thursday, July 29, 2021 11:06 AM To: ProfessorAmanda/econsimulations @.> Cc: Byker, Tanya S. @.>; Mention @.> Subject: Re: [ProfessorAmanda/econsimulations] Git/npm Cheatsheet (#136)

Oh just saw that second bug, no idea what that is...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FProfessorAmanda%2Feconsimulations%2Fissues%2F136%23issuecomment-889224472&data=04%7C01%7Ctbyker%40middlebury.edu%7C076ead209ac648b00fe508d952a26c52%7Ca1bb0a191576421dbe93b3a7d4b6dcaa%7C1%7C0%7C637631679814773145%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=PSjIHyyRHN2umZS5Dw91hid8XoyaiNWSJzs5w4loLVE%3D&reserved=0, or unsubscribehttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAP65VZZFBPSLYGGN32YFFJTT2FU6ZANCNFSM5AP5ZHVQ&data=04%7C01%7Ctbyker%40middlebury.edu%7C076ead209ac648b00fe508d952a26c52%7Ca1bb0a191576421dbe93b3a7d4b6dcaa%7C1%7C0%7C637631679814783145%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=onExRm6TPzhVRQZp2XVlakxsfPdA0mQmbw%2FHqcC5eGo%3D&reserved=0.

ProfessorAmanda commented 3 years ago

For deleting old branches still stored locally: To delete a branch locally, run git branch -d [branchname]. Alternatively, I just did a quick google search and found this command: git branch --merged | egrep -v "(^*|master|development)" | xargs git branch -d, which should delete all old local branches (source).

ethansaxenian commented 3 years ago

For deleting old branches still stored locally: To delete a branch locally, run git branch -d [branchname]. Alternatively, I just did a quick google search and found this command: git branch --merged | egrep -v "(^*|master|development)" | xargs git branch -d, which should delete all old local branches (source).

Did the command work?

ProfessorAmanda commented 3 years ago

Yes, perfectly! Just thought I would store those commands here to close that other issue.

ethansaxenian commented 3 years ago

Great!

ProfessorAmanda commented 3 years ago

Some directions for the future, in case I merge a change from Dependabot that ends up breaking something. (Also directions here for pushing changes from my local).

If Dependabot install something you don't like after you merge a pull request, edit the package.json file in your local to roll back the version. Then do npm install in terminal. git status will show you what has been modified. To "transmit" these changes to the online repository, there are three steps: 1) Stage: 2) Commit 3) Push. To stage the changes, "git add ." Then check git status to see it green. To commit, type git commit -m 'whatever message you want'. Finally, git push.

ProfessorAmanda commented 2 years ago

Hi Wayne, this issue would be a good place to put updated npm commands and other instructions for us. Thanks!

waynew99 commented 2 years ago

I’ve borrowed Ethan’s cheatsheet and made several changes – the most parts are still the same! I put [NEW] in front of the commands that are changed.

I’ve also added a deployment section for the deployment workflow.

Useful commands

To view the site on branch_name:

git checkout branch_name
git pull
npm run dev

If you get a module not found error:

npm install --legacy-peer-deps
npm run dev

To delete all outdated local branches:

git branch --merged | egrep -v "(^*|master|development)" | xargs git branch -d

Deployment process:

  1. Make sure the master branch is ready to deploy – features work, style is correct, no linter errors, no test errors.
  2. Create a pull request from master branch into deployment branch (the direction is important!)Screen Shot 2022-06-29 at 12 11 53
  3. Merge the pull request.
  4. GitHub Action should do its job deploying everything. Monitor the Actions tab for any errors and address if needed.
ProfessorAmanda commented 2 years ago

Hi Wayne, I'm getting some errors when I try to run this locally. I started by running "git pull" for the master branch, then running "npm install --legacy-peer-deps". When I then tried to run "npm run dev," I error that said something like "dev not found." Then I just ran it using "npm start," and was able to run it locally. However, then when I ran "git pull" to make sure everything was up to date, I got an error "error: Your local changes to the following files would be overwritten by merge: package-lock.json Please commit your changes or stash them before you merge." Can you recommend a next step?

waynew99 commented 2 years ago

Hi Amanda, It seems like react changed something in package-lock.json and that prevents a git pull. Let's try git stash before git pull to get rid of local changes. So please try:

git stash
git pull
npm install --legacy-peer-deps
npm start dev

Hope it works!

ProfessorAmanda commented 2 years ago

Okay, I was able to run it! But when I try to check out another branch, I get an error: "error: Your local changes to the following files would be overwritten by checkout: package-lock.json Please commit your changes or stash them before you switch branches. Aborting."

I'm going to stash the changes for now, and we can maybe chat during our meeting.

ProfessorAmanda commented 2 years ago

Hey Wayne, I got this error again just now when I tried to check out NormalDistribution: "Midd-19529:econsimulations agregg$ git checkout NormalDistribution error: Your local changes to the following files would be overwritten by checkout: package-lock.json"

Do you think there might be a tweak we need to make to package-lock.json to make everything agree? There might just be a version number or something that differs among our versions of the repo. I see this warning when I run the npm install step: "npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!"

For now I've just stashed the changes again to see what's up with NormalDistributions.

waynew99 commented 2 years ago

Thanks for the detailed error message. I did a little research and it seems like that there's a difference between the node version of your computer's environment and the node version of our project. I'll try finding potential solutions for us to try out next time we meet. For now, stashing them should be ok.

ProfessorAmanda commented 2 years ago

Btw my issues with package-lock.json seem to have resolved? At least, I'm not having any problems or needing to stash changes when I work with the NormalDistribution branch.

waynew99 commented 2 years ago

I'm not sure what the root cause was, but I'm glad it's not there anymore! If it still occurs with other branches, we can try several solutions next time when we meet.