I'm currently working on a course module for programming scientists, on Git and version control. One of the benefits I'm trying to convey (amongst others), is that using VC can safeguard you against loss of work. But of course, as is well-known, Git gives you ample opportunity to shoot yourself in the foot. It'd be a shame to have students in the course loose work because of using a system that was supposed to prevent that from happening in the first place :-)
My question: would you have tips for things you could teach people (commands, workflows, tricks) that steer them out of trouble when using Git?
Specifically, this applies mostly to people with a solo workflow, without prior Git experience, and possibly beginner-level programmers.
Examples of the kind of tips I'm aware of:
Push your code to something like GitHub or BitBucket regularly. Also, please make backups, too :)
Stay away from commands like git rebase
, until you know what you're doing.
Make a backup of your code directory (including .git
dir) before playing with history rewriting, especially when you're still learning.
Thanks!
I think you're doing things more complicated than needed.
To be able to recover previous state, regular commits to a local repo is all that is required. You don't have to introduce branching or merging at this stage. Maybe tagging as a way to get back to specific versions.
To reduce the risk of loss of code due to a lost computer / crashed hard drive proper backups is a good advice. But that is the same for everything, not just code.
If you want to introduce code sharing, pushing to github or bitbucket is an option. As long as you only push and you're the only one pushing it is very simple.
The most general rule would be: ensure you know what a command does before using it.
It could be declined in more specific tips:
git rebase
, we could say avoiding to change the history.-f
on a comment (push
, clean
, ...)Having a safety net before doing something potentially dangerous is indeed always a good idea. However, no need to copy the whole directory : just putting a tag on your original commit to be able to checkout
it if things goes wrong is enough and less cumbersome.
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