GIT

GIT

● GIT Configurations

  1. System

    Configurations are apply for all the users who use the machine.

  2. Global

    Configurations are apply only for a user who already login to the machine.

  3. Local

    Configurations are apply only for the project.

  • List the Global configurations

    git config --global list


  • Add user email, name and editing tool

    git config --global --add user.email "Type Your Email"

    git config --global --add user.name "Type Your preferred user name"

    git config --global --add core.editor "Type Your preferred software tool to edit your code"

    git config --global --add color.UI "Type true if you want to see the difference between two commitments by color it."

● Three Tree Architecture in GIT

  1. Initialize a git repository

    git init

  2. Show current status of the repository(show edited files)

    git status

  3. Add all the files into staging index from working directory(working copy)

    git add .

    OR

    Add specified file into the staging index

    git add fileName.html

  4. add the files into the repository

    git commit :- add message in the opened file

    OR

    git commit -m "type your message to identify the commitment" :- add message without opening the file using the default editor

● Commands for Commitments

  • Show all the commitments and the point of the head

    git log

    OR

    git log --oneline :- show commitments with hash

  • Go to previous commitments

    git checkout type the preferred commitment with hash tag

● Check difference between commitments,branches,three stages

  • Show the different lines between working directory and staging index.

    git diff

  • Show the different lines between working directory and head.

    git diff HEAD

  • Show the different lines between working directory and commitment.

    git diff type the commitment with hash

  • Show the different lines between staging index and head.

    git diff --cashed HEAD

  • Show the different lines between staging index and commitment

    git diff --cashed Type the commitment with hash

  • Show the different lines between two commitments.

    git diff commit_1 commit_2

  • Show the different lines between two branches.

    git diff branchName1 branchName2

● GIT Branches

  • List all branches

    git branch

  • Add new Branch.

    git branch "barnchName"

  • Rename Branch.

    git branch -m "current name of the branch" "new name of the branch"

  • Delete a branch

    git branch -d "branch name"

  • Shift the branch.

    git checkout "branch name"

  • Merge branch into master branch.

    git merge "branch name"

  • Create a new branch and switched to the newely created branch.

    git checkout -b "branch name"

  • Create a new branch from old commitment.

    git checkout -b "branch name" "commitment with hash"

    OR

    git branch "branch name" "commitment with hash"

● GIT RESET

git reset [option] "commitment with hash"

Comments

Popular posts from this blog