Sitemap
Cheesard

Cheesard

mind/matter. words i put together.

Version control, Git & Github

4 min readNov 27, 2022

--

What is Version Control?

Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. A Version Control System allows you to revert selected files back to a previous state, revert the entire project back to a previous state, compare changes over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more.

What is Git?

Git is a free and open source version control system that tracks changes in source code, enabling multiple developers to work together on projects. While most other version control systems store data as a list of file based changes, git stores it’s data like a series of snapshots taken every time one uses the git command, commit.

What is Github?

GitHub is a web-based code hosting platform for version control and collaboration. It uses Git, the open source version control software that lets multiple people make separate changes to web pages at the same time.

How to create a repository.

One obtain a Git repository in one of two ways:

1. You can take a local directory that is currently not under version control, and turn it into a Git repository using the git init command.

2. You can clone an existing Git repository from elsewhere using the git clone command.

Git Commands

  1. Git config: A convenient way to set configuration options for your Git installation. configurations such as the user’s name and email. This should be used immediately after installing Git on a new development machine.
  2. Git init: This initializes a new Git repository.
  3. Git add: This moves changes from the working directory to the staging area. This gives you the opportunity to prepare a snapshot before committing it to the official history.
  4. Git commit: This command is used to save changes to one’s local repository.
  5. Git branch: This lets you create different isolated development environments within a single repository.
  6. Git status: This displays the state of the working directory and the snapshot. It’s advised to run with git add and git commit to see exactly what’s being included in the next snapshot.
  7. Git checkout: This command is used to switch from one branch to another.
  8. Git remote: This command is used to connect your local repository to the remote server.
  9. Git push: This works to push your code from one’s local git online to the internet
  10. Git pull: This command fetches and merges changes on the remote server to your working directory.
  11. Git push: This command sends the committed changes of master branch to your remote repository.
  12. Git clone: This command is used to obtain a repository from an existing URL.

These are few of the basic git commands. More practice and time using git and github will reveal more and have one more conversant with the various commands.

Get Cheesard’s stories in your inbox

Join Medium for free to get updates from this writer.

Github Workflow.

A Git workflow is a recommendation for how to use Git to accomplish work in a consistent and productive manner. Git offers a lot of flexibility in how users manage changes therefore, there is no standardized process on how to interact with Git. When working with a team on a Git-managed project, it’s important to make sure the team is all in agreement on how the flow of changes will be applied.

A git workflow is considered successful if it enhances the effectiveness of a team and doesn’t burden productivity.

1. Initialize the central repository

First, someone needs to create the central repository on a server. If it’s a new project, you can initialize an empty repository. Otherwise, you’ll need to import an existing Git or SVN repository.

2. Clone the central repository

Next, each developer creates a local copy of the entire project. This is accomplished via the git clone command. When you clone a repository, Git automatically adds a shortcut called origin that points back to the “parent” repository, under the assumption that you’ll want to interact with it further.

3. Make changes and commit

Once the repository is cloned locally, a developer can make changes using the standard Git commit process: edit, stage, and commit. it’s a way to prepare a commit without having to include every change in the working directory. This lets you create highly focused commits, even if you’ve made a lot of local changes.

git status # View the state of the repo

git add <some-file> # Stage a file

git commit # Commit a file</some-file>

3. Push new commits to central repository

Once the local repository has new changes committed. These change will need to be pushed to share with other developers on the project.

git push origin main

This command will push the new committed changes to the central repository.

3. Managing conflicts

The central repository represents the official project, so its commit history should be treated as sacred and immutable. If a developer’s local commits diverge from the central repository, Git will refuse to push their changes because this would overwrite official commits.

--

--

Cheesard
Cheesard

Written by Cheesard

mind/matter. words i put together.