Coder Social home page Coder Social logo

git-learning's Introduction

Get your Git correctly! ๐Ÿ˜Ž

alt text

Git is the most popular distributed version control system. Git was developed by Linus torvalds.

I will list down most essential git commands which everyone should master when handling github repositories.

Git Commands

  1. Set up your reposirory details (username and email).
    git config --global user.name "vidush5"
    git config --global user.email "[email protected]"
  1. Cache your login details.
    git config --global credential.helper cache
  1. Initialize a github repository.

This folder contains all the objects and references that git uses and it creates as a part of your projects's history.

    git init
  1. Add single file to staging area.
    git add helloworld.py
  1. Add multiple files to staging area.
    git add .
  1. Check your repository status.
    git status
  1. Commit your changes in your repository.
    git commit -m "my first commit"
  1. To check commit history with changes.
    git log -p
  1. To view the changes before commiting.
    git diff
  1. To see the staged changes.
    git diff --staged
  1. Remove files
    git rm helloworld.py
  1. Rollback last commit you can rollback the last commit and it will create a new commit, an inverse of the previous commit.
    git revert HEAD
  1. Rollback a particular commit.
    git revert <commit id>
  1. Create a new branch.
    git branch <branch_name>
  1. Switch to the branch.
    git checkout <branch_name>
  1. List down all branches.
    git branch

list down all remote branches.

    git branch -a
  1. Delete a branch.
    git branch -d <branch_name>

To delete forcible a branch.

    git branch -D <branch_name>

The above commands only delete the local copy of the branch, if you want to delete a remote branch follow the below command.

    git push origin --delete <branch_name>
  1. Merge two branches.
    git merge <branch_name>

Merge with commit.

    git merge --no-ff <branch_name>
  1. Push changes to a remote repository.
    git push origin main 
  1. Pull changes from a remote repository.
    git pull

git-learning's People

Contributors

vidush5 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.