Skip to content

Instantly share code, notes, and snippets.

@violetbp
Created February 12, 2020 20:27
Show Gist options
  • Save violetbp/8531cf497315a79f0a8d554071ebee5d to your computer and use it in GitHub Desktop.
Save violetbp/8531cf497315a79f0a8d554071ebee5d to your computer and use it in GitHub Desktop.

To create a new branch and switch to it at the same time, you can run the git checkout command with the -b switch:
git checkout -b issue53

Shorthand for:
$ git branch iss53
$ git checkout iss53

normal commit after changes git commit -a -m 'added a new footer [issue 53]'

OH NO WE NEED TO WORK ON MASTER NOW EVERYTHING IS BORKED AND ISSUE 53 IS WAY LESS IMPORTAINT
commit then switch back to master!
git commit -a -m 'Gotta make sure everything is commited to the branch or git will get mad!'

git checkout master

since we're super fancy we're gonna make ANOTHER branch!
git checkout -b hotfix
nano thefilewiththeissue.co.uk
git commit -a -m 'fixed the broken thingy'

now that its fixed we merge that into master
first we go back to master branch
git checkout master
now we merge it!
git merge hotfix

the branch can now be deleted
git branch -d hotfix

and switch back to the original one, finishing it up
git checkout iss53
nano meowmeow.nya
git commit -a -m 'finished the new footer [issue 53]'

back to master to merge
git checkout master
git merge iss53

IF THERE IS A CONFLICT
git status to see what conflicts are!
then u gotta fix doez conflicts dis is easy if you have an IDE and then git add . or whatevea
upon which you shall run the command "git commit -m "WE DID IT"" as you complete this lil tutorial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment