Git

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

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)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s