Fundamentals 5 min read

Getting Started with Git and GitHub: Essential Commands and Workflow

This article introduces Git as a distributed version‑control system and GitHub as a hosting platform, explains why they are useful, and walks through core commands such as init, add, commit, branch, tag, and push to help developers manage code efficiently and collaborate effectively.

System Architect Go
System Architect Go
System Architect Go
Getting Started with Git and GitHub: Essential Commands and Workflow

Are you still copying old files before a large refactor, constantly using Ctrl+Z to undo changes, or manually copying the latest version to a USB drive? If so, it’s time to embrace Git and GitHub.

What is Git? Git is a free, open‑source, distributed version‑control system where each repository is independent and can work offline; synchronization to a remote server requires network access.

What is GitHub? GitHub is a cloud platform that hosts Git repositories. It hosts millions of open‑source projects from companies like Google and Facebook, allows you to fork projects, file issues, contribute code, and even serves as a social network for developers.

Common Git Commands

Installation : Numerous online tutorials are available; the article does not repeat them.

Initialize a repository (any folder becomes a working directory):

git init

After initialization a hidden .git directory is created to store all version‑control metadata.

Add files to the repository (two steps: add to the staging area, then commit to the current branch, usually master):

git add . // the dot adds all files in the current directory git commit -m 'your commit message' // each commit generates a unique commit‑id

The relationship between working directory, staging area, and branches is illustrated in the original diagram (omitted here).

Version changes :

git reset --hard <commit_id> git log // view commit history to find the commit_id

Tagging (useful for marking releases):

git tag <tag_name> <commit_id>

Collaboration with branches :

git branch <branch_name> // create a new branch git checkout <branch_name> // switch to the specified branch

Synchronizing with a remote GitHub repository :

git remote add origin <repository_url> // link local repo to remote git push // upload local commits to the remote repository

Alternatively, create an empty repository on GitHub, clone it locally, then perform add, commit, and push operations as usual.

For more detailed Git usage, refer to Liao Xuefeng’s blog (search “git Liao Xuefeng”).

Happy coding!

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

software developmentGitcommand-lineGitHubVersion ControlCollaboration
System Architect Go
Written by

System Architect Go

Programming, architecture, application development, message queues, middleware, databases, containerization, big data, image processing, machine learning, AI, personal growth.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.