Setting up a git environment & pushing code to GitHub

Setting up a git environment & pushing code to GitHub

Steps are highlighted as follows:

  1. Download Git and install
     https://git-scm.com/download/win
    
  2. Once git is installed,
     run the gitbash
    
  3. If the working directory is on the master, which is usually the default, change it to main by running the following command
     $ git branch -m master main 
    
  4. On your gitbash command line
      cd desktop     
      cd project folder 
    
  5. Initialize the local directory as a git repository by running these commands
      $ git config --global user.email "your email address on github goes here"   
      $ git config --global user.name "your username on github goes here"    
      $ git init 
    
  6. Add the files in your new local repository so as to stage them for the first commit by running this command
      $ git add .
    
  7. Commit the files that you've staged to remote repo by running this command
      $ git commit -m "your first commit title goes here"
    
  8. In the command prompt, add the URL for the remote repo where your local repo will be pushed to by running

      $ git remote add origin URL       
      $ git remote -v 
    

    Note: At the top of your repo on github (the repo you have created that you want your code to be pushed to),

     you will see "quick setup". 
    
     Navigate to the far right and copy the remote repo URL by clicking on the copy snippet.        
    
  9. Push the changes in your local repo to github by running this command
      $ git push origin main    
    

A pop-up comes up on your browser from git trying to link to your github,
Click authorize
and Tada,
Your code is being pushed.

So you are good.

If this sounds more like a boost to you, please like, share or comment