Menu
The Tech Paper
  • Home
  • Interview Questions
    • PHP String Interview Question
    • PHP Array Interview Qutions
    • jQuery Interview Quetions
    • PHP Interviwe Question on php.ini file
    • htaccess File Interview Quetions
  • About
The Tech Paper

Git Commands

Posted on January 8, 2020May 26, 2021

git –version

Set user name and email
git config –list ( for list all configuration settings)
git config –global user.name “abhinav”
git config –global user.email “abc@yopmail.com”

Remove git added file:
git reset <filename>

Remove git commit file: local changes will not remove
git reset HEAD^
git reset HEAD ~ 1

Remove git commit with changes:
git reset –hard HEAD^

Create Git .ignore file by command
touch .gitignore
touch .gitignore

Ignore git tracked file:
git rm –cached a.log
git rm -r –cached logs

Exclude from the management of Git
git update index –assume-unchanged .env.example

Restore to the management of Git
git update index –no-assume-unchanged .env.example

Create branch from local:
git checkout -b new_branch_name

Move code from One git account to Another one:
git remote set-url origin GIT-HTTP-URL (from first account)
git pull origin BRANCH-NAME
git remote set-url origin GIT-HTTP-URL (from second account)
git push origin BRANCH-NAME ( or you can create new branch on local then push that branch)

If you want to save some file for work later or ignore files while branch change then you can save file by git stash
git stash — file_name

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • Docker
  • Git
  • Interview Questions
  • Laravel
  • Linux
  • php
  • Salesforce

Recent Posts

  • Nested / Cascade query in SOQL
  • Declarative tools in salesforce
  • SalesForce SU21 mind dumps
  • PHP Interview Question 2021
  • Ubuntu 20.04 Bluetooth not working [Resolved]

Archives

  • May 2022
  • September 2021
  • April 2021
  • January 2021
  • December 2020
  • September 2020
  • July 2020
  • January 2020
  • July 2019
  • August 2018
  • June 2018
  • April 2018
  • September 2017
  • June 2017
  • May 2017

Recent Posts

  • Nested / Cascade query in SOQL May 11, 2022
  • Declarative tools in salesforce September 24, 2021
  • SalesForce SU21 mind dumps September 24, 2021
  • PHP Interview Question 2021 April 24, 2021
  • Ubuntu 20.04 Bluetooth not working [Resolved] January 22, 2021

Contact Us

©2022 The Tech Paper | Powered by Abhinav Trivedi