Simplifying Git and GitHub for Developers

Simplifying Git and GitHub for Developers

Version Control using Git, Collaboration with Github

·

5 min read

About Git

Git is a Version Control System that intelligently tracks changes in files. Git is particularly useful when you and a group of people are all making changes to the same files at the same time.

A version control system, or VCS, tracks the history of changes as people and teams collaborate on projects together. As developers make changes to the project, any earlier version of the project can be recovered at any time.

What is GitHub ?

GitHub is an online SaaS service. GitHub is a cloud-based platform where you can store, share, and work together with others to write code.

Storing your code in a "repository" on GitHub allows you to:

  • Showcase or share your work.

  • Track and manage changes to your code over time.

  • Let others review your code, and make suggestions to improve it.

  • Collaborate on a shared project, without worrying that your changes will impact the work of your collaborators before you're ready to integrate them.

Collaborative working, one of GitHub’s fundamental features, is made possible by the open-source software, Git, upon which GitHub is built.

About Repository

A repository, or Git project, encompasses the entire collection of files and folders associated with a project, along with each file's revision history.

Git repositories are self-contained units and anyone who has a copy of the repository can access the entire codebase and its history.

Git Setup

git config --global user.name “[firstname lastname]”

To set a name that is identifiable for credit when review version history

git config --global user.email “[valid-email]”

Basic Git commands.

To use Git, developers use specific commands to copy, create, change, and combine code. These Commands can be directly executed from command line, code editor like VS Code, Intellij idea, or GitHub desktop.

  • git init : It create a repository and begins tracking the existing directory.

  • git clone: It used to copy a remote repository that already exist. The clone includes all the project's files, history, and branches.

  • git add : It stages a file. Git tracks changes to a developer's codebase, but it's necessary to stage and take a snapshot of the changes to include them in the project's history.

  • git commit : It saves the snapshot to the project history and completes the change-tracking process. In short, a commit functions like taking a photo.

  • git status : It shows the status of changes as untracked, modified, or staged.

  • git commit -m “[descriptive message]” : It commits your staged content as a new commit snapshot.

  • git branch : It will list your branches. a * will appear next to the currently active branch.

  • git branch [branch-name] : It creates new branch at the current commit.

  • git merge [branch] : It merge the specified branch’s history into the current one.

  • git push : It transmit local branch commits to the remote repository branch.

  • git pull : It fetch and merge any commits from the tracking remote branch.

  • git log : It show all commits in the current branch’s history.

Example of how we push our remote file to git.

Git after committing changes

Here's an example of git clone.

Command : git clone [URL]

Here's an example of pushing local branch to remote git.

Here's how you create a pull request

Navigate to your repository on GitHub and click on "New Pull Request". Provide a clear description for the Pull Request.

Now we merge branches using command line.

git fetch : Fetch the latest change.

git checkout : "base branch name".

git merge : "New branch name".

Example :

GitHub features

GitHub Codespace : Spin up fully configured dev environments in the cloud with the full power of your favorite editor. GitHub Codespaces is an instant, cloud-based development environment that uses a container to provide you with common languages, tools, and utilities for development. GitHub Codespaces is also configurable, allowing you to create a customized development environment for your project.

GitHub Pull Request : Allow contributors to easily notify you of changes they've pushed to a repository – with access limited to the contributors you specify. Easily merge changes you accept.

GitHub Issues: GitHub Issues are items you can create in a repository to plan, discuss and track work. Issues are simple to create and flexible to suit a variety of scenarios. You can use issues to track work, give or receive feedback, collaborate on ideas or tasks, and efficiently communicate with others. Essentially they serve pivotal point for collaborating or communicating among various element in a system.

CI/CD GitHub: CI/CD automates your builds, testing, and deployment so you can ship code changes faster and more reliably.

  • Continuous Integration : Automatically builds, tests, and integrates code changes within a shared repository.

  • Continuous Delivery : Automatically builds, tests, and integrates code changes within a shared repository.

  • Continuous Deployment : Automatically deploys code changes to customers directly.

GitHub Actions: You can automate, customize, and execute your software development workflows right in your repository with GitHub Actions. You can discover, create, and share actions to perform any job you'd like, including CI/CD, and combine actions in a completely customized workflow.

Conclusion

As we have gone through the Git and GitHub, its common command, its features that how git revolutionize your workflow. GitHub action has CI/CD that simply automate building, testing, deployment so that developer can only focus on writing code and GitHub ensure the quality and efficiency. There are still so much to discover in git.

Resource :

https://docs.github.com/en

https://github.com/features