This question explains how to set up a local Git repository and push it to Github.
- Go to https://git-scm.com/downloads and click “Download For Windows”.
- Select 32 bit or 64 bit according to your PC architecture.
- Open the downloaded
The installation wizard will ask for basic information like the installation path, whether create desktop icons or not etc. You can leave them all in their default settings or make necessary changes and press “Next”. Ultimately, you will see the “Install” button at the end and it will begin the installation process.
Open a terminal window and enter the following command, it will update the local software repository.
sudo apt-get update
Then install Git using the following command.
sudo apt-get install git
Homebrewif not already installed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Install Git
brew install git
Visit https://git-scm.com/downloads and click “Download for Mac” for more information and alternative installation methods.
Check The Installation
Run the following command, it should display the installed Git version.
Create Your First Git Repository
First, create a new directory.
Go into that directory.
Initialize a new local Git repository
Create a file called
hello-git.html or otherwise, you can add your code files.
Add some content into
hello-git.html file and check the status of the repository. It will display the changed files.
hello-git.html to the repository.
git add hello-git.html
If you have multiple files, you can add them all by using
git add -A
Commit changes with a short and meaningful message like what you did in the commit.
git commit -m "hello-git.txt added"
Push To Github
Set the Github username. Your username is the part after the 3rd forward-slash (
/) of your profile URL. For example, in
bitcoin is the username.
git config --global user.username your_github_username
Create a new repository in Github by visiting https://github.com/new.
Link the Github remote repository to the local repository.
git remote add origin https://github.com/your_github_username/hello-git.git
Push local repository to Github repository.
git push origin master