Menu
GIT : Setup/Configuration & Useful Commands
Git setup/Configuration :
1. ssh-keygen -t rsa -C "Email ID"
: for key generator (.ssh folder)
# Generating public/private rsa key pair.
# Enter file in which to save the key (/c/Users/you/.ssh/id_rsa or ~/.ssh/id_rsa):
[Press enter]
Now you need to enter a passphrase.
# Enter passphrase (empty for no passphrase): [Type a passphrase]
# Enter same passphrase again: [Type passphrase again]
Which should give you something like this:
# Your identification has been saved in /c/Users/you/.ssh/id_rsa.
# Your public key has been saved in /c/Users/you/.ssh/id_rsa.pub.
# The key fingerprint is:
# 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db "Your Email Id"
Copy that Key and paste into (Go to bitbucket Setting -> Click on SSH Key -> Add New key)
2. ssh -T git@github.com : for check key is proper or not
3. For name : git config --global user.name "Name"
4. For email : git config --global user.name "Email ID"
Direct Existing Repository Commit on Git
Pull/Push on Existing Repository on Git
1. git status
2. git add .
3. git status
4. git commit -m "Message"
5. git pull origin "Branch Name"
.
6. git add .
7. git commit -m “Merge code "message"
”
8. git push origin “branchname”
Commons Useful command of Git
git config –global user.name “XXXXXXX”set username
git config –global user.email “xxxxxxxxx@gmail.com”set username
git init set username
git status
git add . Will add all files
git add filename
Single file
git rm – -cached filename
Will remove that file
git commit -m message
Single commit
git log display Git log
git log end move to view log end and with this shortcut Shift + zz
git diff before commit diff b/w any file
git diff –cached after commit diff
git log – – oneline
git commit -a -m “msg”
ssh-keygen -t rsa -C “xxxxxxxx@live.com” : for key generator (.ssh folder)
ssh -T git@github.com for check key is proper or not
git remote add origin git@bitbucket.org:xxxxxxxxl/xxxxx.git when we want to share git project on the server. that means server URL.
git branch list of branch
git branch Branch Name
list of branch
git checkout Branch Name
switch to another branch
git checkout -b Branch Name
Will create a new branch and switch to created branch
git merge Branch Name
Merge branch
git checkout hashcode
git reset –hard 5b0c8327813ff97628f53513ea84abee81a3f9fb
git revert 63f3e7e37420438c11e2460c40952f45c124b346 a2ec8091431341e5154e47c085252ba1d58cca02
git rm readme.md Remove particular file
git stash Use git stash when you want to record the current state of the working directory and the index, but want to go back to a clean working directory. The command saves your local modifications away and reverts the working directory to match the HEAD commit.