git branching experimental

Well I’ve been working for a project. today I was experimenting with windows specific wchar and I needed to do change a lot of code since morning and I ended up with an ugly mess. That I can clear out latter but right now I need to do some mainstream works on last working commit. But I don’t want to loose this work. So how can I keep this work in some branch for future and revert my workspace back to last commit ?

  • Forking vs. Branching in GitHub
  • What is the easiest/fastest way to find out when a git branch was created?
  • How git branches and tags are stored in disks?
  • Accidentally created a branch called --track, and now I can't delete it
  • Using git-svn to merge a svn branch back into trunk and trunk back into the branch
  • TFS 2010: How to produce a changelog (ie. list of work items) between two releases of the application using labels?
  • I need to un-fetch some revisions from git-svn
  • How to integrate PHPed with Git
  • How come “git pull origin master” doesn't actually change the files in my computer's directory?
  • Git: How to see old version of a file (before it was added to the staging area/index)?
  • How do I clone a github project to run locally?
  • I can't see my remote branch
  • 4 Solutions collect form web for “git branching experimental”

    You can create a new branch and commit your changes to it:

    git checkout -b topic/ugly-mess
    git commit -a -m 'Checkpointing mess.'

    Then go back to your mainstream branch which has the last working commit:

    git checkout master

    If you want your to publish your “local mess” upstream, push the branch:

    git push origin topic/ugly-mess

    Simply create a new branch

    git branch -b wchar_migration

    and commit your changes into it

    git commit -am "wchar ..."

    then go back to your work

    git checkout master

    If later you want to include the modification you made on master, simply rebase on it.

    git co wchar_migration
    git rebase master

    You probably don’t even need a branch. If you use git stash, git stashes (stores) the current ‘dirty’ workspace and returns you to a clean workspace. You can apply the stashed changes later if you want.

    So long as you haven’t committed any of this work, you can always git stash your experiment.

    But you’ve described this as experimental so another option, and probably the better one, is to keep this work in it’s own branch, e.g. git checkout -b wcharExperiment, commit the work into this new branch, then checkout your main branch.

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