Giter Site home page Giter Site logo

git's Introduction

Git

Git step by step

  1. Initial Setup in Local :
  • Setting up username and email in local :

    1. git config --global user.name annmaryvinod

    2. git config --global user.email [email protected]

  • Checking :

    1. git config user.name

    2. git config user.email

  1. Some Basic Command Lines and their usage :
  • Change Directory "cd .." : to go back to the adjacent parent directory.

  • Change Directory "cd Documents" : to dive into 'Documents' directory.

  • List : " ls " / " dir " : to list the contents of the current directory.

    Note: "dir" is for Windows. " ls " also works for Windows.

  • Make Directory : " mkdir Playground " : creates a new directory named Playground.

  • Creating a file in mac or cmd(windows) : " touch index.html " : creates an index.html file.

  • Remove a file : " rm index.html " : deletes the index.html file

  • Remove a directory : " rmdir Playground " : deletes the directory named Playground.

  1. Some real GIT commands :

    • Initialising a git repo in the local :

      command : " git init "

      this can be used to initialise or create a new repo in an empty or non empty folder in the local

    • Checking the status of a repo ( to find the staging,committed files etc) :

      command : " git status "

      this shows the unstaged files (untracked files),committed files etc.

    • To stage a file :

      command : " git add index.html"

      index.html is added to the staging area (can be checked with " git status ")

    • To unstage a staged file :

      command : " git rm --cached index.html "

      removes index.html from the staging area (can be checked using " git status ")

    • To add multiple files to the staging area :

      command : " git add . "

    • Commiting :

      command : git commit -m "fixed a bug in the header"

  • Commit History :

    1. To see all info :

    command : " git log "

    1. To get a condensed form (crisp):

    command : " git log --oneline "

  • Undoing Things :

  1. checkout : read-only command. It can take us back to the code at a particular commit

    " Eg : Boss wants to see the code at the end of the second commit (just to see)"

    * command to get to the specified commit :  "git checkout 4dc777b "
    
    * command to get back on the top :  "git checkout master "
    
    
    
        Note : 4dc777b refers to the id of the second commit. This can be obtained from the commit history
    
  2. revert : Undo a commit

    * command : " git revert 4dc777b "
       
       Now a screen pops up asking for a commit msg requirement.
       Press Shift + colon.
       Then type "wq"
    
    • " git log " shows a new commit of revert
  3. reset : permanent deletion. Reset to a specified commit. All commits after the specified commit will be deleted.

    • command : " git reset 4dc777b --hard "

    resets to the 4dc777b commit

  • Branch

    1. create a branch : " git branch view " (creates a branch named view)

    2. list all branches : " git branch -a "

    3. switch branches : " git checkout view " (switched to the view branch)

    4. delete branch : " git branch -d view " (deletes the view branch only if it is merged) " git branch -D view " (delets the view branch even if not merged)

                  Note : before deleting move to the master branch
      
    5. Create and checkout simultaneously : " git checkout -b view " (creates and switches to the view branch)

    6. Merging :

      • switch to the master before merging

      • command : " git merge view " (merges the view branch to the master)

NOTE : Most important video is the 10th tutorial in netninja

  • Fork : used in open source development. Copies a particular code.

git's People

Contributors

annmaryvinod avatar

Watchers

 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.