DEV Community

DakshitaVanga
DakshitaVanga

Posted on

Git

Directory->Folder
CLI->Command Line Inteface
cd->change directory
Repository->Project,or the folder

-> clone
-> add
-> commit
-> push
-> pull

README.md(md: mark down)

git add .
git status
git commit

SSH Keys :
To push code, you need to prove that you are the owner of the github account.
Connect local machine to github using SSH keys

ssh-keygen -t rsa -b 4096 -C "emailId"

testkey.pub-> public key (put on github)
testkey->privatekey

cat[Unix: that reads files sequentially, writing them to standard output] -> type[windows]

Add your SSH private key to the ssh-agent
Adding your SSH public key to the github

Github Workflow:
write code -> Commit changes -> make a pull request

Local Git Workflow:
write code -> stage changes(git add) -> commit changes(git commit) -> push changes (git push) -> make a pull request

git remote rm origin
git remote add origin git@github.com:username/myapp.git

Git Branching:
git branch (list of all branches)
git checkout -b 'newBranchName'
git checkout BranchName

git diff (compares two branches and shows lines which have been changed, before merge)
git merge branchName

Undoing:

Undo staging: after git add-> git reset
Undo commit: after git commit-> git reset HEAD~1
Completely remove: git reset --hard commitHash

git log

Forking:
Fork others repo, to have complete control over the code.

//////////////////////////////////////////////////
git init
git add .
git commit -m "Initial Commit"
git remote add origin [url]
git push -u origin master

Top comments (0)