Last updated on August 15th, 2020
Git is a widely-used version control system used to manage code. The code managed with Git is called a Git repository. Here is how to commit to Github.
Steps
- Check for Git Version.
$ git --version
If it is not showing the version of git then go to the official website of git and download the git according to the OS of your system.
- If you are setting up the git for the first time, you can configure the git with name & email.
$ git config --global user.name Your_Name
$ git config --global user.email Your_Email
- Initialize a Git repository.
$ git init
- Tell Git to start tracking your files and folders:
$ git add
If you want to track a single folder or file, use its name:
$ git add app/
$ git add config/routes.rb
- Verify that everything was committed correctly
$ git status
- Save the changes you made, with a message describing what changed:
$ git commit -m "Initial Commit"
- On GitHub, create a new repository with a short, memorable name:
~ In Github, use the drop-down menu and select New repository on the top right-hand corner.
~ Type a short, memorable name for your repository.
~ Optionally, add a description of your repository.
~ Choose to make the repository either public or private.
~ Select Initialize this repository with a README.
~ Click Create repository.
- Add a remote repository, and then push your local repository to the remote repository.
$ git remote add origin https://github.com/{owner}/{repositoryname}.git
$ git push -u origin master