Giter Site home page Giter Site logo

git-notes's Introduction

Create New Branch with Current Changes
then commit in the new branch and switch back to master

git checkout -b topic/newbranch


Copy branch to master without merging or making a "merge" commit
then do more work before committing to master

git merge --squash branchA


Copy existing branch to new branch and squash
then check in as one commit, or diff with master

// assuming you're already on old_branch
git checkout -b new_branch
// squash the last 3 commits
git rebase -i HEAD~3


Merge specific files from another branch

git checkout source_branch <paths>...


Merge a branch, solving all conflicts by keeping changes from the branch

git merge --no-commit -X theirs somebranch


Get latest from master into current branch
possibly rebase or merge?

git checkout current_branch
git rebase master


Compare file between branches

git diff master -- "C:\path\file.cs"


Change file in prior commit

git rebase --interactive 'bbc643cd^'
git commit --all --amend --no-edit
git rebase --continue


Change prior commit message

// change last commit
git commit -m "corrected message" --amend
// change second last commit
git rebase -i HEAD~2


Change prior commit date

git commit --amend --date="Fri Feb 1 22:39:25 2019 -0500"


Undo a commit

// this left the commit in the history, but I updated the files and re-committed with the same message
git reset HEAD~1
git reset --soft HEAD~1


Undo a merge

git reset --hard HEAD~1


Undo a rebase

// find the actions to undo
git reflog
git reset --hard "HEAD@{5}"


Delete Local Branch

git branch -d branch_name


Recreate a branch after it was deleted

git checkout -b <branch> <sha>


Pull Requests

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.