Seems like for both Mercurial or Git, if I don't commit first, then I can't push?
So if I don't commit (when not ready yet), I can't push to a remote server to back up my code? The code is in a notebook computer, being carried around, which can be somewhat fragile being carried around.
No, you must make a commit before you can push. What is being pushed is the commit (or commits).
Yes, you do need add and commit your changes before pushing your code to your github repository.
Commit - committing is the process which records changes in the repository. Think of it as a snapshot of the current status of the project. Commits are done locally. Push - pushing sends the recent commit history from your local repository up to GitHub.
You are always ready to commit.
Commit often. Commit to a work in progress branch and distribute it as widely as you feel.
When you get to the state that you're currently referring to as "ready to commit", examine the divergence of your branch from the upstream, do a rebase -i
to clean it up and make it look like you want.
This will be easier, safer, and just generally give you better results than trying really hard to get everything perfect before committing. Remember: A commit doesn't necessarily represent a desired permanent state of the universe. It's just somewhere you are. How you publish it is up to you.
git makes it very easy to publish a do-not-look-at-me
branch for your work in progress that you can later move into your official codebase at whatever point and in whatever form you think best suits you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With