DEV Community

Cover image for Working With Git And Github
Maxwell Wokocha C.
Maxwell Wokocha C.

Posted on

Working With Git And Github

What is Git?

Git is a free and open source software for distributed version control, tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development.

Essential Git Commands:

. Git Push: The "git push" command is used to upload local repository content to a remote repository.
w
. Git Commit: A "git commit -m" takes a snapshot of your repository at one point in time. The "-m" flag helps you add a message to the commit.

. Git Add: The "git add" command adds a change in the working directory to the staging area. It informs Git that you want to include updates to a particular file in the next commit.

. Git Remote Add Origin: The "git remote add origin" creates a new, empty Git repository on your remote server.
Note: You will have to obtain the "git remote add url for the remote repository and add credentials if needed.

How To Push From Our Local Environment To GitHub:

. Download Git Bash.

. Configure Git Bash.

. Work With The Configured Environment.

. Clone Your GitHub Repository.

. Push To GitHub.

. Show The Content.

No 1. Download Git Bash (The Version Compactible With Your Operating System).

No 2. Configure Git Bash: This gives the Git Bash an identity
. "git config --global user.name "add hostname"

. "git config --global user.email "add email"

. "git config --list" verifies that your configuration is in place.

No 3. Work With The Configured Environment:

. Create A Directory Called "Website": "mkdir website"

. Get Into The Created Directory: "cd website"

. Initialize The Directory: "git init" - This command turns the directory called "Website" into a local Git repository.

. To Check The Status Of The Directory: "git status"

. Create A File Inside The Directory Called "Index.html": "touch index.html"

. Open The index.html File: "vim index.html" - Move Into Insert Mode To Be Able To Make Modifications Inside The File.

No 4. Clone Your GitHub Repository.

. Go To Your GitHub Page. Click On The + And Create A New Repository.


. In The Next Page Click on "Code" And Select HTTPS Then Copy The url.

. Go Back To Git Bash To Clone The Repository With The Command "git remote add origin url"

No 5. Push To GitHub.

We Need To Move The File We Added To File Index.html To The Staging Area.

. Check The Status Of The File: "git status"

. Complete The Staging Of The File Content With The Command: "git add index.html"

. Check The Status Again To Verify.

Note: The Highlighted Red File Name Has Just Turned Green To Show That The Staging Level Of The File Content Is Complete.

. Create A SnapShot Of The Whole Update With The Command: "git commit -m"

. Push File To GitHub: "git push origin master"

No 6. Show The Content.

In The GitHub Page And Push The Live URL To View The File Content.

Thank You For Your Time. Till The Next Post.

Top comments (0)