
Git reset -hard HEAD~2 # Go back 2 commits, you will lose uncommitted work. This can be achieved by branching and "rolling back", like so: git branch Sometimes you may need to move several of your recent commits to a new branch. If a given branch name is only found on one remote, you can simply use git checkout -b To create a branch from a remote branch (the default is origin): git branch / another branch name, commit SHA, or a symbolic reference such as HEAD or a tag name): git checkout -b some_other_branch The can be any revision known to git (e.g. To create a branch at a point other than the last commit of the current branch (also known as HEAD), use either of these commands: git branch To create a new branch and switch to it: git checkout -b To switch to an existing branch : git checkout Generally, the branch name must not contain spaces and is subject to other specifications listed here. To create a new branch, while staying on the current branch, use: git branch

This allows you to start a new history that records a set of paths similar to by easily running “git commit -a” to make the root commit. This should create a new branch namely hello-git-branch. The index and the working tree are adjusted as if you had previously run “git checkout “. The first commit made on this new branch will have no parents and it will be the root of a new history totally disconnected from all the other branches and commits. Enter -orphan for the checkout-command:Ĭreate a new orphan branch, named, started from and switch to it. As I didn’t plan this upfront, I obviously didn’t have an empty branch for that and I didn’t want to create one and have all the other commits in it.

GitHub Pages can be setup separately for every repository and you can choose to select a branch for your HTML-files.
#Git create branch and checkout code#
In this project I’m using Asciidoctor and the Gradle Plugin as suggested by my friends Ralf and Gernot in their column Hitchhiker’s Guide to Docs as Code and corresponding repo. Much like creating a branch from a commit, you can also create a branch from a tag.
One of the learning scopes of the above project is “code as documentation” and the question to which extend such a project can be used to write articles and generate documentation. git branch master git branch commit-branch 735c5b4 git branch commit-branch master You can also use the git checkout -bI wanted to start publishing to GitHub Pages from my learning and experimenting project simple-meetup.
