How to work on a project on 2 local machines?
I'll be working on projects on my laptop and desktop. I initially started it on my laptop.
If I now fork/clone the github repo onto my desktop, make changes, then commit them, am I still doing the below on my desktop?
git add .
git commit
git push -u origin master
or is there something else I do on desktop, vs laptop?
10 Replies
Don't fork it. Just clone it down and setup origin.
commands will be the same on both, just make sure you are pulling changes before working
ahhh yeah pull, that makes sense, thanks b1 🙂 pull the most recent repo -> work -> push changes -> repeat
instead of using master, i strongly recommend you to create a branch for the feature you're working, which avoids that you push half-assed/half-baked features you were working with
and you can continue working on it on both machines
I'll look into that, kinda makes sense, would help me learn branching too
Personally I don't do feature branches much (which I should probably) but I def always have two branches (dev/pub)
pub only gets pushed to for deployments
i've been doing feature branches at work, and helped me a lot
treating master as a black box that only receives fully working and tested code will help you a lot
imagine you're working on adding a form, but you didn't finish it
if you put it into master, it's possible you lose track of it and get stuck without knowing what you were doing exactly
if you have a branch, you can always compare back to master and see how far you were into it
then you can pick up where you left off of, and test that change
then, you can just grab the whole thing and merge to master, in one go
if you want to keep your sanity, you can squash all the commits and merge, which keeps a clean history
if you need to revert a huge feature because you won't use it anymore, you know exactly what you need to change
I’ll look into that, thanks epic. Be good to get comfortable with branching
you're welcome
it is a lot easier than you imagine
Something we do on a project I'm helping with is have a GitHub Action that builds a Docker container & deploys a Google Cloud Run instance for every pull request.
(That sample code looks pretty complicated because it's building an Express instance which backs a Hasura instance which is used to server-side render a Next.js app.)
It's really handy to sanity check pull requests by seeing the code that will be merged in action.
Vercel will also build PR instances if you connect a GitHub repository.
it does make things a lot of sense to test it like that