How to create a GitHub Repository
Creating your first GitHub Repository
git config user.email "YOUR SECOND GIT EMAIL ADDRESS"
git add
git commit -m "first commit"
- Prerequisite: You have a local project ready which you wish to push to your GitHub repo and you have git installed on your machine.
- Open terminal and cd to your local project directory.
- Initialize the project directory as a Git repository.
- Open github.com in your browser and log in with your GitHub account, if you don't have an account already, create one. Click on the "New repository" button displayed on the page. This will take you to "Create a new repository" page. Enter the name you will keep for your repository in the "Repository name" text field. You can choose to initialize your repository with a README file and also add a .gitignore file, but this is optional.
- Click on Create repository button and your repository will be created and you will be redirected to your repository page.
- Click on "Clone or download" button and copy the URL displayed therein. You can Clone using SSH or HTTPS. I am using SSH here as you can see in the screenshot below.
- Now its time to go back to our terminal and add the remote address as the URL we copied in the previous step.
- Next, you can add your username and email in the config file if it is different from what you have in your global config. If you are not sure what I mean, you can still go ahead and do this, it will not be of any harm.
git config user.email "YOUR SECOND GIT EMAIL ADDRESS"
- You can now do a git pull to get the README or .gitignore file you have added in your remote git repository.
- Now you are ready to do your first commit. Start it by doing a git status, then add your files you want to push and finally do your first git commit to this repo.
git add
git commit -m "first commit"
- Go back to your browser and refresh the page, you will be able to see your code now in your Git repo.
- Optional Step: If your upstream is not set properly or you are not sure if it has, set the upstream explicitly by running the below command.
Comments
Post a Comment