rohansanghai/git-basic-commands

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 

Repository files navigation

Click ⭐ if you like the project. Pull Requests are highly appreciated.


No.Questions
1Git: Configuration
2Git: starting as a repository
3Git: staging files
4Git: committing to a repository
5Git: pulling and pushing from and to repositories
6Git: branching
  1. Before you start using a git. Git wants you to do registration with git

    To tell Git who you are, run the following two commands:

        $ git config --global user.name "mentionedYourGitUsername"
        $ git config --global user.email "mentionGitRegisterEmailId"

    We are able to see the outputs from many git commands in the terminal. We can have colorful out for the commands what we are running in terminal.

    To turn on code highlighting, just run the following command:

        $ git config --global color.ui true

    The last basic configuration command will let you view your Git configurations. Running this command is the same as asking for a copy of your contract:

        $ git config --list
        user.name=GitUserName
        user.email=GitRegisterdEmailId

    ⬆ Back to Top

  2.     $ git init

    The "init" command stands for initialize. Once you run "git init", Git will initialize a hidden directory called ".git" in the project's root directory.

    To know the Git status, you'll need to run:

        $ git status

    ⬆ Back to Top

  3.     $ git add <file-name>
    
        $ git add <file-name> <another-file-name> <yet-another-file-name>
    
        $ git add .
    
        $ git add --all
    
        $ git add -A
    
        $ git add --cached <file-name>
    
        $ git reset <file-name>

    ⬆ Back to Top

  4.     $ git commit -m "Add Files"
    
        $ git reset --soft HEAD^
    
        $ git commit --amend -m <enter your message>

    ⬆ Back to Top

  5.     $ git remote add origin <link>
    
        $ git push -u origin master
    
        $ git add <file-name>
    
        $ git clone <clone URL>
    
        $ git pull

    ⬆ Back to Top

  6.     $ git branch
    
        $ git branch <branch-name>
    
        $ git checkout <branch-name>
    
        $ git merge <branch-name>
    
        $ git checkout -b <branch-name>

    ⬆ Back to Top

  7.     $ git diff <file-name>
    
        $ git checkout <file-name> undo changes made in file
    
        $ git stash - remove all changes
    
        $ git clean -fx - remove untracked files
    
        $ git log - 
    
        $ git log --all -- Display All Commits
    
        $ git log -3 -- View most recent commits

    Filter Commits By Author or Committer

        $ git log --author <name>
        $ git log --committer <name>

    View All Diff of Changes for Each Commit

        $ git log -p

    View Summary of Changes for Each Commit

        $ git log --stat

    Help

        $ git help

Releases

No releases published

Packages

No packages published