Git cheat sheet

Create a branch from existing branch

git checkout -b new_branch_name source_branch_name

Specifying -b causes a new branch to be created

Merge another branch to current branch

git merge --no-ff another_branch_name

The –no-ff flag prevents git merge from executing a “fast-forward” if it detects that your current HEAD is an ancestor of the commit you’re trying to merge.

Git merge with their changes

git reset --hard <branch_name>
git pull -s recursive -X theirs

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s