DEV Community

JohnOdhiambo
JohnOdhiambo

Posted on

2

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

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (1)

Collapse
 
ark7 profile image
M.Ark

Good insight about the git.

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay