Git Introduction and command lines

Steps to create GitHub Repository

  • Create a GitHub Account
  • Create a new Repository on the GitHub Account
  • Create a new Project on Desktop or Laptop
  • Install Git Bash
  • Locate the folder of the project and open Git Bash here
  • Use git init to track the project
  • Use git status to check the files which we were about to add. 
  • Then use git add . / git add -A to stage all the files in the current branch of the repository. Now use git status to check if all the files are staged.
  • Then use git commit -m "commit-name" to commit the files to the branch of the repository and use git status to confirm there is nothing else to commit.
  • Then use git remote add origin "url" to connect the remote repository.
  • Once the repository is connected, use git push -u origin "branch-name" to push the files in the branch of the repository. 

Basic Commands

  • git --version - Shows the version of Git.
  • git config - Shows the configuration of Git.
  • git config --global user.name "xxxxxxx" - Sets user name of the Git System.
  • git config --global user.email "xxxxxxx@xxxx.com" - Sets user email of the Git System.
  • git config --global user.password "xxxxxxxxxx" - Sets user email of the Git System.
  • git config --list - Shows the details of the configuration of the Git System.
  • git help config - git help <verb> - Shows the help information of a particular Git Verb.
  • git config --help - git <verb> --help - Shows the help information of a particular Git Verb.
  • ls - list - Shows all the folders in the directory.
  • ls - la - Shows all the files and folders in the directory.
  • git log - Gives the logs of the project that is committed.
  • touch .gitignore - Creates .gitignore file in the directory.

Stash Commands

  • git branch "branch-name" - It will create a new branch

  • git checkout "branch-name" - Switch the current branch to "branch-name"

  • git diff

  • git stash save "stash-name" - Creates a new stash and all the changes in the file will be wiped out. But you can retrieve the changes later.

  • git stash list - Shows the list of stashes in a branch

  • git checkout “stash-index” - Used to retrieve codes which are saved in the stash-name.

  • git stash apply - applies the top stash on the branch of the repository

  • git stash apply "stash-index" - applies the stash index on the branch of the repository.

  • git stash pop - removes the top stash from the list.

  • git stash drop - deletes the top stash from the list.

  • git stash clear - deletes all the stashes from the branch.

  • git stash show -p | git apply --reverse - reverse the applied stash

Rebase Commands

  • git checkout "branch-name" - Switches the project to the branch-name.
  • git rebase master - Moves the branch on the tip of the master branch.
  • Hello World

Create Personal Token for GitHub

Use the following steps:
  • Login to your GitHub account
  • Click Profile and then go to Settings >> Developer Settings >> Personal access tokens
  • Click Generate New Token. Give a name to the token, set the permissions and click Generate token.

Reference

  1. Hello World




Comments

Popular posts from this blog

Architecture Components in Android

DataBinding in Android

SSLSocketFactory in Android