git checkout master
git pull
git checkout branchname
git merge master
I made some changes on the master but I want to bring (and commit) them to a different (NEW) branch.
git stash save
git checkout -b <new_branch>
git stash pop
git stash save
git checkout <branch_name>
git stash pop
git clone https://github.com/theleagueof/chunk
git subtree split --prefix=folder_name -b new_branch
git remote add upstream https://github.com/user/repo
git push upstream new_branch
# then create a master branch
git tag -a v0.2 -m "Version 0.2 of chimp"
git push origin v0.2
git tag -d 12345
git push origin :refs/tags/12345
git branch newbranch
git reset --hard HEAD~3 # Go back 3 commits. You *will* lose uncommitted work.*1
git checkout newbranch
# https://help.github.com/articles/configuring-a-remote-for-a-fork/
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
I messed up the commit history on my branch and I don't really care. I just want to have a fresh commit in the branch with all the changes I made.
Yeah it's bad, but still it happens. Of course you can do a rebase, but sometimes this is annoying or complicated. A (bit weird) alternative is the folllowing:
git checkout feature_branch
git reset --soft master # keeps the changes, gets rid of the commit history
git add -A # pay attention to that!
git commit -m "Committing all at once."