Home > Blockchain >  newb git, what if I forget to checkout main and my scheduled script runs?
newb git, what if I forget to checkout main and my scheduled script runs?

Time:06-04

I'm working with local git repos for now. Let's say I branch a script in main to 'alpha' and check it out to work on something. At the end of the day, I forget to checkout/merge to main (might not be the right process or phrasing). Later that evening, the task scheduler on my computer runs the script.

Does the scheduler end up running my branch? How do I make sure it runs main instead of the branch? Is there a standard way that this should be done/managed?

CodePudding user response:

After messing around with this a bit. It would appear that the file is swapped out with whatever branch was last checked out. So the scheduled task in the above senario would run the branch.

If anyone has a better way to manage this than 'check out the main branch at the end of the day' I would still love to hear it.

CodePudding user response:

The important point to understand here is that git doesn't just manage files in a single directory, it manages a version history which can be shared with any number of "working copies". That's how several people can work on the code at the same time, each committing to a different branch, and then merging their changes together later.

In your case, you can think of the task scheduler as a different member of your development team - while you leave your working copy in whatever state you're working in the middle of, the task scheduler can have its own working copy, with the latest version of the main branch checked out at all times. You could even have an extra scheduled task, which runs before your overnight script, which runs a git pull on that extra copy to bring in any changes you've merged to master.

On the other hand, assuming this is just on a development server anyway, why not just let it run your current version overnight, as an extra test?

  •  Tags:  
  • git
  • Related