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).

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 ?

  • Troubleshooting misplaced .git directory (nothing to commit)
  • One-Time Git Commit using Filesystem Created as Author Date
  • Git discarded uncommitted changes after checkout
  • Confusion between merge and commit in Git
  • git aborting commit immediately - Brackets editor
  • What is a convenient way of writing a multiline commit message?
  • Remove a commit's parent, thereby making it the initial commit
  • Edit a commit message using source control in Xcode
  • 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:

    1. git checkout -b merge_classes
    2. # writing some code
    3. git add .
    4. git commit -m "merged two files
    5. git checkout master
    6. 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.

    Git Baby is a git and github fan, let's start git clone.