A New Way Of Adding Git Commits
A New Way Of Adding Git Commits
We've all been there.
We all learn how to code. And then we all learn:
git add .
git commit -m "add a message in the present tense"
git push
But what if it wasn't so simple as that?
I've been working with some really cool developers
One of the best things about my new job is the absolutely amazing cool new developers who I can work with.
The biggest blessing of all is the fact that I work with fewer people but closer and more regularly.
This has to be the greatest gift of all. And so one of my current manager has taught me some really cool things.
And one of the biggest things is a new way to approach my code in git
What my manager has been having me do instead is this:
When I create a new file that needs to be tracked (or files):
git add somefile.py some_other_file.py
And then from then on:
git add -u
git commit -m "send more code to the repository"
git push
The git add -u stands for "git add update".
Why would you do this?
It helps protect you from accidentally pushing the wrong files to main.
You might have a file where you test out something highly confidential and you might want it on your local branch but you don't want to accidentally push it to GitHub.
Similarly, you might want to have a file where you just test things and play around with things, especially if you are a junior like me.
You don't want that up on GitHub.
You especially don't want that live in your production code.
You just have to remember to add all of the new files
I am so grateful every day to have such wonderful people to work with and to learn things from!!! I am so lucky! Thank you. I feel so grateful and happy and lucky for my new job.
Comments
Post a Comment