Approach to handling such code change with Git
Here is the problem :
I would like to merge two classes called Song each, both do share most members but not all. Populating their contents won’t be problem in case members are not found, they will be simply ignored, so probably okay but who knows, I might have to revert back to the original implementation (separate objects).
- Is it possible to get the time/date of a commit knowing the commit hash but without access to the repository?
- Is there a way to display a message to an end-user when they commit a file in Git?
- Apply stash with untracked files already committed
- nodegit - how to get lines added/removed in a commit filewise?
- How to add multiple files in git for a single commit?
- Why is git revert telling me “bad revision” when I use a commit hash?
This is where Git comes handy, for versioning my code. (that’s my first time I use it)
Question is : how one would handle such change with Git ? create a commit or create a branch ?
2 Solutions collect form web for “Approach to handling such code change with Git”
Git is flexible and allows you to do what you want, however you want. Since you’re debating between making a commit vs. making a branch it sounds like you’re debating between committing to master or doing your work on another branch. If that’s the case than I’d highly recommend branching off your master branch, doing your work, and when ready, merging back into master.
The steps you would take are:
git checkout -b merge_classes
# writing some code
git add .
git commit -m "merged two files
git checkout master
git merge merge_classes
A commit will certainly be involved somehow, but if you are talking about the same file for the class
Song, but with two different content, then a branch must be created.
That would allow you to manage different content for a common file, and perform a merge later.
If this is about making one file from two existing files, then a simple commit is enough, and you will be able to revert if you need to go back to the original situation.