All Projects → gabrieldejesus → Git Commands

gabrieldejesus / Git Commands

Licence: mit
👨🏾‍💻 The main git commands that every developer should know.

Projects that are alternatives of or similar to Git Commands

Lcnewfeature
几行代码快速集成新特性界面!
Stars: ✭ 109 (-20.44%)
Mutual labels:  guide
The Math Behind A Neural Network
📄 The math behind the neural network used for Olivia
Stars: ✭ 119 (-13.14%)
Mutual labels:  guide
Short Gitlab Tutorial
Get started with Gitlab in practicable time
Stars: ✭ 127 (-7.3%)
Mutual labels:  guide
Site Launch Checklist
☑️ A checklist of miscellaneous tasks to do before launching a public website.
Stars: ✭ 110 (-19.71%)
Mutual labels:  guide
Guide To Staying Productive
If you're looking for ways to stay motivated and focused, while still having fun, this guide is for you! Contributions and any kind of improvements are very welcome!
Stars: ✭ 116 (-15.33%)
Mutual labels:  guide
Activiti 7 Developers Guide
https://activiti.gitbook.io/activiti-7-developers-guide/
Stars: ✭ 120 (-12.41%)
Mutual labels:  guide
Bitcoin Programming With Bitcoinjs
Bitcoin Programming with BitcoinJS, Bitcoin Core and LND
Stars: ✭ 109 (-20.44%)
Mutual labels:  guide
Golang For Nodejs Developers
Examples of Golang compared to Node.js for learning
Stars: ✭ 2,698 (+1869.34%)
Mutual labels:  guide
Neural Network From Scratch
A Neural Network implemented from scratch (using only numpy) in Python.
Stars: ✭ 118 (-13.87%)
Mutual labels:  guide
Kotlin Quick Guide
A quick guide to Kotlin for developers.
Stars: ✭ 127 (-7.3%)
Mutual labels:  guide
Guide
Screwdriver.cd Documentation
Stars: ✭ 113 (-17.52%)
Mutual labels:  guide
Ethereum Staking Guide
Ethereum 2.0 Staking Guides
Stars: ✭ 116 (-15.33%)
Mutual labels:  guide
Guides
A repository of technical guides for various technologies
Stars: ✭ 122 (-10.95%)
Mutual labels:  guide
Technical Interview Megarepo
Study materials for SE/CS technical interviews
Stars: ✭ 1,480 (+980.29%)
Mutual labels:  guide
Guidetomastodon
An increasingly less-brief guide to Mastodon
Stars: ✭ 129 (-5.84%)
Mutual labels:  guide
Angular To React Redux
Angular to React/Redux, a Guide for Angular v1 Experts Looking to Learn React/Redux
Stars: ✭ 109 (-20.44%)
Mutual labels:  guide
Guidepages
引导页/首次安装引导页/渐变引导页/APP介绍页/功能介绍页
Stars: ✭ 119 (-13.14%)
Mutual labels:  guide
React Redux Typescript Guide
The complete guide to static typing in "React & Redux" apps using TypeScript
Stars: ✭ 11,621 (+8382.48%)
Mutual labels:  guide
Express Env Example
A sample express environment that is well architected for scale. Read about it here:
Stars: ✭ 130 (-5.11%)
Mutual labels:  guide
Frontend
18F's Front End Guild –  content has been moved to https://github.com/18F/development-guide
Stars: ✭ 126 (-8.03%)
Mutual labels:  guide
Main Git Commands

Stars Forks Issues GitHub license Follow gabrieldejesus

Main Git Commands

English   |    Português   

  • Starting a Repository

    git init


  • Listing Modified Files

    git status


  • Undoing Changes

    • Unmonitored files

      git checkout

    • To delete new files that have not yet been added to the Stage

      git clean -df

    • Removing files from the Stage

      git reset

    • Undoing the last commit

      git revert HEAD


  • Rename Commit

    git commit —amend


  • Branches

    • Listing local Branches

      git branch

    • Also list the branches that are in the remote repository

      git branch -a

    • Going to another branch

      git checkout my-branch

    • If you add -b a new branch will be created

      git checkout -b my-new-branch

    • Excluding branches

      git branch -d branch-name // normal

      git branch -D branch-name // forcing

    • Renaming branches

      git branch -m new-branch-name

    • If you are on a branch and want to rename another one, you must first pass the current name of the branch you want to rename:

      git branch -m current-name new-name

    • Orphan Branch An orphaned branch has this name because it is not linked to the main branch, so their histories are not shared.

      Example:
           i --- j --- k <== branch 'my branch'
                 /
         a --- b --- c --- d --- h --- l <== branch 'main'
             \ /
               and --- f --- g <== branch 'my other branch'
    
         1 --- 2 --- 3 --- 4 <== `orphaned 'branch
    

    This can be useful when you want to place more than one project in the same repository. A good example is when you have a project on Github and want to create a website to publicize your project. The application and the website are different things, therefore, their codes must be versioned separately. Having both in the same repository simplifies management.

    To create an orphaned branch just use the command:

    git checkout --orphan my-branch-orphan


  • Viewing Commit History

    git log

    • History of one or more files

      git log -p my-files

    • Author's history

      git log --author = name-author

    • History by date

      git log --after = "MMM DD YYYY"

      git log --before = "MMM DD YYYY"

    • History Based on a message (commit)

      git log --grep products

      With this command we will have the history of commits in which the commit message has the word “products”. What we go through can be a regular expression, and we can spend more than one:

    Examples:

    Search for "products" OR "users"

    git log --grep products --grep users

    Search for "products" AND "users"

    git log --grep products --and --grep users


  • Display branches in a more readable mode

    It is possible to have the history printed showing the branches of the repository with something more readable and in color with a command. We will have a result similar to this:

      * a102055 (HEAD -> master) commit 8
      | * 196d28e (branch-2) commit 7
      | * 07e073c commit 3
      | * 2b077ca new fie
      | | * c1369d8 (branch-3) commit 6
      | | * d11bdcd commit 5
      | | /
      | / |
      * | 2b22b75 commit 2
      | /
      * d5a12b0 .gitignore
      * 9535426 - commit 1
    

    The command is a little long:

    git log --all --decorate --oneline --graph

    To decorate everything we should write after the log.

      --all
      --decorate
      --oneline
      --graph
    

  • Working on more than one thing without committing

    There may be times when you need to stop what you are doing and start working in another task. However, it may not be good to commit something that has not yet been finalized and then return to it, resulting in a commit that will be in the history but it has code that doesn't work. We can save these changes made even without having to perform a commit to later work on it again, which is called a Stash (something like "hide" or "accumulate").

    By doing this, your repository will return to the state of the last commit, and the changes previously made will be “hidden”.

    • Saving changes to a Stash

      git stash

    • You can still put a name on this stash

      git stash push -m my-name-stash

    • Listing Stash

      git stash list

    • Recovering modifications

      git stash apply

    This will retrieve the most recent stash code. If you want to recover a stash oldest, just look at the number of the stash that appears when we list it and pass for the following command:

    git stash apply stash @ {2}

    • Removing Stashes

      When we retrieve changes from a stash, it remains saved. To delete it from the stack, run the drop command next to the name of the stash you want to remove

      git stash drop stash @ {5}


Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].