Skip to content

Instantly share code, notes, and snippets.

@dilipsuthar97
Last active July 28, 2021 15:58
Show Gist options
  • Save dilipsuthar97/41b4a9e2bab3cd0205b4f38649ecbc45 to your computer and use it in GitHub Desktop.
Save dilipsuthar97/41b4a9e2bab3cd0205b4f38649ecbc45 to your computer and use it in GitHub Desktop.

Git Config Guid

Installation

  1. Download & Install git first

Config

  1. git config —global user.email "<your git email>"
  2. git config —global user.name "<your git username OR name>"

Create new repository

  1. Create new repository on your github profile from here
  2. Go to your projects root folder and open cmd in windows or terminal on mac and run below commands step-by-step
  3. git init
  4. git add .
  5. git commit -m "😉 initial commit"
  6. Now copy your github repository url from your newly created repository and paste it in below command
  7. git remote add origin <GIT_REPOSITORY_URL>
  8. git remote -v to check your remote url added successfully or not
  9. git branch to view your current branch(master) name
  10. git push -u origin master push code on github server
  11. git pull take pull of code from remote (github server) (for later use)

New branch

  1. git branch list out all current branched for your it maybe master for first time
  2. git branch <NEW_BRANCH_NAME> create new branch
  3. git checkout <NEW_BRANCH_NAME> to change your working branch and go to newly created branch
  4. After doing your changes in code run below commands
  5. git add .
  6. git commit -m "modified code"
  7. git push -u origin <NEW_BRANCH_NAME>

Delete branch

  1. Go to another branch from branch that you want to delete
  2. git checkout master
  3. git branch -d <NEW_BRANCH_NAME> delete branch from local machine
  4. git push origin --delete <NEW_BRANCH_NAME> delete branch from remote

Reset last local commit

  1. git reset HEAD~ [All the changes will remain same]

Merge branch from local

  1. git checkout master
  2. git merge dev merge dev branch into master branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment