Code Monkey home page Code Monkey logo

git-commands's Introduction

git-commands

Frequently used git commands

initialize git

git init

see what you have changed since the last commit

git diff

stage files for committing

git add .

commit changes

git commit -m "Made some changes"

create a branch and switch to it

git checkout -b issue87

list branches

git branch

switch to a different branch

git checkout issue13

change remote

git remote remove origin

git remote add origin https:#github.com/dancancro/ng2-redux-form

save changes without committing them so you can go to a different branch and come back later

git stash

restore stashed changes

git stash apply

push the current branch to the same name on the remote

git push origin HEAD

compare two branches

git diff branch1..branch2

delete a local branch

git branch -d branchname

delete a remote branch

git push origin --delete branchname

merge a branch into another branch

git checkout dest_branch

git merge source_branch

discard all unstaged changes in the current branch

git checkout -- .

Remove untracked files from the working tree

git clean -xfd

git branch mynewbranch git git reset --soft HEAD~3 # only if you want to undo last 3 commits git checkout mynewbranch

git checkout master git merge --squash bugfix git commit

Undo last commit without undoing the changes.

Do this so you can see the differences between your files and a previous commit. Repeat the command until you reach the point against which you want to compare your current files

git reset --soft HEAD~

Rename a branch

  1. Rename your local branch. If you are on the branch you want to rename:

git branch -m new-name

If you are on a different branch:

git branch -m old-name new-name

  1. Delete the old-name remote branch and push the new-name local branch.

git push origin :old-name new-name

  1. Reset the upstream branch for the new-name local branch. Switch to the branch and then:

git push origin -u new-name

Useful articles

Writing a good commit message Set of useful commands like this but much better

git-commands's People

Contributors

dancancro avatar

Watchers

James Cloos avatar

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.