Git for coursework: the four commands that save a semester
Every semester someone loses a project the night before the deadline: a laptop dies, a file gets overwritten, a group member's version silently replaces yours. Git prevents all of it, and you need four commands to get most of the benefit. You do not need to understand branches yet.
Set up once. Install Git, create a free account on GitHub or GitLab, and in your project folder run git init. That folder is now tracked.
Command 1: git add . This stages everything you changed. Think of it as putting papers on the desk to be photographed.
Command 2: git commit -m 'what I did'. This takes the photograph. Write what changed in plain words: 'added login form', 'fixed marks calculation'. A year from now, 'update' tells you nothing. Commit every time you finish a piece, several times a day.
Command 3: git push. This sends your photographs to the server. Now a dead laptop costs you nothing after the last push. Push at the end of every session, no exceptions.
Command 4: git log --oneline. This shows the list of photographs. When something breaks, git checkout followed by the commit id on any file brings that file back to how it was. That is the whole reason you did the other three.
Group work, one rule: nobody sends zip files over Messenger. Everyone clones the same repository, everyone pushes, and if two people changed the same line Git says so instead of silently keeping one. Learn git pull before you start working and git push when you stop, and merge conflicts become a thing you handle in five minutes rather than a thing that ends the friendship.
What to leave out of the repository: passwords, API keys, and node_modules. A file named .gitignore lists what to skip. A key pushed to a public repository is public forever, even if you delete it a minute later, because the photograph of it still exists.
The branch, merge and pull request workflow that companies use is the next step, and the Coding & Development Hub is the place to ask about it. But four commands, used every day, are what separate the students who lose work from the ones who do not.
0 Comments
Loading comments…