DEV Community

JohnOdhiambo
JohnOdhiambo

Posted on

Common Git commands

--globally configure username
$ git config --global user.name "JohnDoe"
$ git config user.name "JohnDoe"

--globally configure password
$ git config --global user.email "johndoe@gmail.com"
$ git config user.email "johndoe@gmail.com"

--Navigate to previous directory
$ cd ..

--navigate to the stated directory
$ cd My_Portal/ChannelsPortal

--Add a specific file
$ git add 'My_Portal_lattest.bak'

--Add all files
$ git add .

--Commit changes
$ git commit -m 'Db Commit'

--Add to the remote repository
$ git remote add origin https://github.com/JohnDoe/My_APIs.git

--Push to the master repository
$ git push -u origin main

$ git push origin master --force

ADD A SINGLE FILE
LENOVO@DESKTOP-PIVU MINGW64 /e/Learning/ReactJs (Main)
$ git init

LENOVO@DESKTOP-PIVU MINGW64 /e/Learning/ReactJs (master)
$ git add 'Intro_To_React.html'

LENOVO@DESKTOP-PIVU MINGW64 /e/Learning/ReactJs (master)
$ git commit -m "First React Commit:file"

LENOVO@DESKTOP-PIVU MINGW64 /e/Learning/ReactJs (master)
$ git branch -M main

LENOVO@DESKTOP-PIVU MINGW64 /e/Learning/ReactJs (main)
$ git remote add origin https://github.com/JohnDoe/ReactJS.git

LENOVO@DESKTOP-PIVU MINGW64 /e/Learning/ReactJs (main)
$ git push -u origin main

HOW TO CLONE FROM EXISTING REPO
$ git clone https://https://github.com/JohnDoe/Read.git(url to be cloned)
$ cd name-of-folder
$ git add .
$ git commit "comment"
$ git set-url https://https://github.com/JohnDoe/Tech.git(url to your repo)
$ git push -u origin main

HOW TO ADD AN ENTIRE FOLDER
$ git add foldername
$ git commit -m "commit comment"
$ git push

Top comments (1)

Collapse
 
ark7 profile image
M.Ark

Good insight about the git.