How to create a GitHub Repository

Creating your first GitHub Repository
  • 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. 
 cd /your-local-project-directory-path/
  • Initialize the project directory as a Git repository.
git init
  • 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.  
 git remote add origin git@github.com:git-account-name/git-repo-name.git
  • 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.name "YOUR SECOND GIT USERNAME"
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.  
 git pull origin master
  • 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 status
git add 
git commit -m "first commit"
  • You can now again check your commit by running git status. Its time you push this commit to the remote repository by using git push command.
git push -u origin master
  • 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.  
git branch --set-upstream-to origin/master 

Comments

Popular posts from this blog

Get rid of "Timed out receiving message from renderer"

Selenium Grid using Zalenium

Selenium - How to initialize Chrome and Firefox WebDriver