DEV Community

michael akello
michael akello

Posted on

Connecting GitBash to GitHub(Step-by-step Guide)

Getting started with GitHub and GitBash is key for any developer, Here is a quick guide to link the two for a windows O.S.

Initial Steps;

  1. Install GitBash - https://github.com/LuxDevHQ/Data-Tools-Installation-Guide?tab=readme-ov-file#git-bash
  2. Set Up a GitHub Account.
  3. Create a personal Access Token in GitHub.

    steps

    1. click your Profile picture (Top Right)
    2. Go to settings
    3. Scrol to Developer settings
    4. select personal access tokens
    5. Click Token(classic)
    6. Click generate new token(classic) -copy and save your token safely(you wont see it again).

open GitHub

create a Project directory.

$ mkdir GitLink
Enter fullscreen mode Exit fullscreen mode

change directory into the created directory.

$ cd GitLink
Enter fullscreen mode Exit fullscreen mode

initialize Git.

$ git init
Enter fullscreen mode Exit fullscreen mode

configure your identity

$ git config --global user.name akellomichael
$ git config --global user.email michaelomondiakello@gmail.com
Enter fullscreen mode Exit fullscreen mode

connect to your GitHub repository.

create a repository on GitHub, then link it:

$ git remote add origin https://github.com/akellomichael/GitHub_GitBash-Connection 
Enter fullscreen mode Exit fullscreen mode

Verify the connection:

$ git remote -v
Enter fullscreen mode Exit fullscreen mode

Authenticate Using Your Token.

update the remote URL to include your username and token.

$ git remote set-url origin https://akellomichael:Git_Token@github.com/akellomichael/GitHub_GitBash-Connection
Enter fullscreen mode Exit fullscreen mode

pull all commits(if any) from the remote repo:

$ git fetch origin
Enter fullscreen mode Exit fullscreen mode

create your first file.

$ touch gitlink_doc.md
$ code gitlink_doc.md
Enter fullscreen mode Exit fullscreen mode

Add some content via your default Editor, save and close the file.

Stage the changes.(Add all)

$ git add .
Enter fullscreen mode Exit fullscreen mode

Commit your changes. - create a snapshot of your currently staged project.

$ git commit -m "First Draft"
Enter fullscreen mode Exit fullscreen mode

push to Github

 $ git push --set-upstream origin master
Enter fullscreen mode Exit fullscreen mode

subsequent pushes;

 $ git push 
Enter fullscreen mode Exit fullscreen mode

Hurray!! Your link was successful. GitBash linked to GitHub.

Top comments (0)