DevOps

Ultimate Git Guide: From Basics to Advanced Version Control

 Git is a distributed version control system (VCS).
That means it helps you keep track of changes in your code (or any files), collaborate with others, and manage versions of your project.

Think of it like a time machine for your code:

  • You can save snapshots of your project at any point (commits).
  • You can go back to any previous version.
  • You can create branches to experiment with new features without breaking the main code.
  • Multiple developers can work on the same project without messing up each other’s work.

Example:

  • You’re building a website.
  • On Monday, you write the homepage and save it in Git (commit).
  • On Tuesday, you try a new design in a branch.
  • If you like it ? merge into the main project.
  • If you don’t ? discard without affecting the main code.

GitHub is a cloud-based hosting platform for Git repositories.

Git is the tool, and GitHub is a service that makes it easier to:

  • Store your Git repositories online.
  • Collaborate with other developers from anywhere.
  • Share your open-source or private projects.
  • Use features like Pull Requests, Issues, Actions (CI/CD), Project Boards, etc.

Example:

  • You write code on your laptop with Git.
  • You push it to GitHub so your team can see it.
  • Your friend clones the repository, adds a new feature, and makes a Pull Request.
  • You review and merge it.

 

  • Git = Your personal notebook (you write, erase, and track changes).
  • GitHub = A library where you store and share your notebook so others can read, contribute, or collaborate.

 

git-scm.com
git config user.name
git config user.email
git config --global username.name <user-name>
git config --global user.email <user-email>


git init
git status
git add .
git commit -m "message"
git remote add origin <url>
git push -u origin master
git log
git branch
git remote origin
git remote show origin
git remote add <remote> https://www.github.com
git branch -M <branch_name>
git merge <branch_name>

to push the project from your cloned reportitory to a new repo in your own account:
1.git remote set-url origin <new repor url>
2.git push origin master


you may also need to configure your local repor to use your new repor as the defsult push location :
git push --set-upstream origin master


git branch -d <branch_name>

 


About author

author image

Amrit panta

Fullstack developer, content creator



Scroll to Top