Overview on GitHub
GitHub is among the most popular websites that provides teams the ability to carry out version control (VC). It is built on git, a popular decentralized version control system.
In software development, Git tracks changes made to the source code, hence enabling developers to collaborate and manage different versions of their product. GitHub provides an interface for hosting git repositories.
GitHUb Operations
Various operations in GitHub allow developers to host their git repositories and track their changes. The most common operations are commit, push, and pull.
Commit
Committing your code entails recording a snapshot of the changes to one or more files in your project.
First, one needs to add the file(s) they need to make changes to by invoking the command:
git add <file_name>
This places them to the staging area.
To commit your changes use the command:
git commit -m "Message describing your changes."
Push
The other operation is push. It used to upload your local repository content to a remote repository (such as GitHub).
To do so, use the command:
git push
In case you have a branch, use the command:
git push <remote-name> <branch-name>
prerequisites before pushing
- You must have a local Git repository with committed changes on your computer.
- A remote repository (like GitHub) linked to your local one. You can check your configured remote repos using the command:
git remote -v
- The necessary permissions to write to the remote repository.
Pull
Pulling is aimed at updating your current local working branch with the latest changes from a remote repository.
Use the command:
git pull
In case your are pulling from a specific remote branch, use:
git pull <remote_name> <branch_name>
Hint: Always ensure that you are always on the correct branch. You can use the command:
git checkout <branch_name>
Top comments (0)