HOW TO PUSH CODE FROM A LOCAL REPOSITORY TO A REMOTE REPOSITORY LIKE GITHUB USING GIT BASH
Published: 2024-07-12 16:39:11

From you computer search pane, type git bash and launch it. 
On the bash page start by running the command as in the pics below


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0r3qgbdqfk1yssv3st2k.png)
click enter

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/menj223vyktkur1ch23v.png)
click enter.

**_Explanation_**
- git config: This is the command to configure Git settings.
- --global: This option specifies that the configuration change should apply globally, meaning it will affect all Git repositories on your system.
- user.name: This is the setting being configured, which specifies the author name used for commits.

When you run git config --global user.name <your_name>, you're setting the author name for all future commits to <your_name>. This information is stored in the Git configuration file (~/.gitconfig on Linux/macOS or %USERPROFILE%\.gitconfig on Windows).

For example, running git config --global user.name "Kelechi Abiti" would set the author name to "Kelechi Abiti" for all future commits.

Note that you can also set the email address associated with your commits using git config --global user.email <your_email>.

Setting your username and email address correctly is important because it helps identify you as the author of commits and allows others to contact you about your contributions to a project.
_next command_


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uj6ai33jwinpdm4p4jp8.png)
mkdir lovely is a command to create a new directory (folder) named "lovely".

Here's a breakdown:

- mkdir stands for "make directory" and is a command used to create new directories.
- lovely is the name of the directory you want to create.

When you run mkdir lovely in your terminal or command prompt, it will create a new folder named "lovely" in your current working directory.

For example, if your current directory is /Users/yourname/Documents, running mkdir lovely would create a new folder at /Users/yourname/Documents/lovely.

The mkdir command is a fundamental command in computing, and it's used to create new directories to organize files and other directories.
_next_


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/16qh9n1yd6it0i9jlknn.png)

- cd stands for "change directory" and is a command used to navigate through the file system.
- lovely is the name of the directory you want to switch to.

When you run cd lovely in your terminal or command prompt, it will change your current working directory to the "lovely" directory.

For example, if your current directory is /Users/yourname/Documents and you run cd lovely, your new current directory would become /Users/yourname/Documents/lovely.

The cd command is used to navigate through the file system, and it's essential for working with files and directories. Some other examples of cd usage include:

- cd .. to move up one directory level
- cd ~ to move to your home directory
- cd / to move to the root directory


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g8vbq1lxqjub4ynxrkxz.png)

git init is a command used to initialize a new Git repository in the current directory.

When you run git init, Git sets up the necessary infrastructure to track changes and version your code. Here's what happens:

1. A new .git directory is created in the current directory. This directory contains all the metadata and version history for your repository.
2. A master branch is created, which will be the main branch for your repository.
3. Git sets up the basic configuration for the repository, including the default branch and remote tracking information.

By running git init, you're essentially telling Git to start paying attention to the files in your directory and prepare to track changes. This is the first step in creating a new Git repository.

Some key points to note:

- git init only needs to be run once for a given directory.
- It's usually run in the top-level directory of a project.
- After running git init, you can start using other Git commands like git add, git commit, and git log to manage your code.

So, git init is the starting point for version control with Git!
**_next_**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e81777vkctqjbho2wvuw.png)

touch index.html is a command used to create a new, empty file named "index.html" in the current directory.

Here's what happens:

- touch is a command that creates a new file or updates the timestamp of an existing file.
- index.html is the name of the file to be created.

When you run touch index.html, a new file named "index.html" is created in the current directory. The file is empty, meaning it contains no content.

The touch command is often used to:

- Create a new file for editing or writing content
- Update the timestamp of an existing file (e.g., to mark it as recently modified)
- Create a placeholder file to reserve a filename

In the case of index.html, this file is often the main entry point for a website or web application, and it typically contains HTML content.

So, touch index.html is a quick way to create a new HTML file, ready for you to add content and build your web page!
_**next**_


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/60ktsogo4l1ubovy8drs.png)

- vim is the command to launch the Vim text editor.
- index.html is the name of the file to be opened.

When you run vim index.html, Vim will:

- Open the file "index.html" in the current directory
- Allow you to edit the file using Vim's commands and features
- Display the file's contents in the terminal or command prompt

Vim is a highly configurable and feature-rich text editor that is popular among developers and power users. It has a steep learning curve, but offers:

- Efficient editing capabilities
- Customizable keyboard shortcuts
- Advanced text manipulation features
- Integration with other tools and plugins

By opening "index.html" in Vim, you can edit the file using Vim's unique keyboard-focused interface. If you're new to Vim, don't worry – you can always learn the basics and become a Vim master!


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jlwkfdwbwm2yv65gzumc.png)

when the vim text editor is opened, you can open a different page and type www.chatgpt.com. when the page opens, search for a sample html resume for a particular designation of your choice.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ptjybdfob7bsim8a4ypp.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0t64d18bkpnnqam2dgtz.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wejvdbnonsy6cgsk73wj.png)


copy and paste the sample resume in the editor page, hit the "I" button on your keyboard to be able to insert and make changes in the html file.
Aftermaking the changes, hit the escape button, then hold the shift and; key the type wq and enter and it will take you to the bash page.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z2vpw7ian4xmjerqcr6a.png)
git add index.html is a command that stages the file "index.html" for the next commit.

Here's what happens:

- git add is the command to stage changes for the next commit.
- index.html is the name of the file to be staged.

When you run git add index.html, Git:

- Adds the latest changes made to "index.html" to the staging area (also known as the index).
- Prepares the file to be committed in the next git commit command.
- Snapshots the current state of the file, ready to be committed.

The staging area is like a holding area where you prepare changes before committing them. By staging a file, you're telling Git that you want to include those changes in your next commit.

Think of it like preparing a package to be shipped:

- git add is like putting the file in a box (staging area).
- git commit is like shipping the box (committing the changes).

By staging "index.html", you're preparing it to be committed, making it a part of your project's version history.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/60h3n34wlnsmbaft7rbz.png)
git commit -m "my first commit" is a command that commits the changes you've staged, with a meaningful message to describe the commit.

Here's what happens:

- git commit is the command to commit the changes in the staging area.
- -m is an option to specify a commit message.
- "my first commit" is the commit message, enclosed in quotes.

When you run git commit -m "my first commit", Git:

- Takes a snapshot of the changes in the staging area.
- Creates a new commit with the changes.
- Assigns the commit message "my first commit" to the commit.
- Updates the branch (e.g., master) to point to the new commit.

The commit message is important, as it provides a brief description of the changes made in the commit. This helps you (and others) understand the history of the project and what changes were made at each step.

By committing with a meaningful message, you're:

- Documenting your progress
- Making it easier to understand the project's history
- Creating a reference point for future changes

Congratulations, you've just made your first commit!
**_next_** 
go to www.github.com, click create a new repository, type the repository name, check public,check add a README file and click create repository.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b9g1ijkoitxzz47j3ipo.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8e1ihei77loyhim1a2uk.png)

click on the created repository, g
click on code and copy the link from the HTTP

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8r8cj0nayak6zvkdtccr.png)
Goto git bash page and type the command
git remote add origin and paste the link you copied from github

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nv6uyjigltr376g2qpa7.png)

git remote add origin <url> is a command that adds a remote repository to your local Git repository, named "origin", and specifies its URL.

Here's what happens:

- git remote add is the command to add a remote repository.
- origin is the name given to the remote repository (a common convention).
- <url> is the URL of the remote repository, such as a GitHub or GitLab repository.

When you run git remote add origin <url>, Git:

- Creates a new remote repository reference named "origin".
- Associates the URL with the remote repository.
- Allows you to push (upload) your local changes to the remote repository.
- Allows you to pull (download) changes from the remote repository.

By adding a remote repository, you're connecting your local repository to a central location where collaborators can access and share code. This enables you to:

- Push your changes to share with others.
- Pull changes from others to stay up-to-date.
- Collaborate on the same project.

The "origin" name is a common convention, but you can use any name you like. The URL should point to the remote repository you want to connect to.

Now, you're ready to push your changes to the remote repository and collaborate with others!
**_next_**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/csgype9z4hgkv3oregai.png)

git push origin master is a command that uploads your local changes from the "master" branch to the remote repository named "origin".

Here's what happens:

- git push is the command to upload changes to a remote repository.
- origin is the name of the remote repository (added earlier with git remote add).
- master is the branch you're pushing changes from (usually the main branch).

When you run git push origin master, Git:

- Packs your local changes into a bundle.
- Uploads the changes to the remote repository ("origin").
- Updates the remote "master" branch with your local changes.
- Makes your changes visible to others who pull from the remote repository.

By pushing your changes, you're:

- Sharing your work with collaborators.
- Updating the central repository with your latest changes.
- Making your changes available for others to pull and use.

Remember, git push only uploads changes committed locally (with git commit). If you've made changes but haven't committed them, you'll need to commit and then push.

Now, your changes are live in the remote repository, and others can access them!
**_next_**
goto github repository page you copied the link from, click on settings,from the left hand side, click pages, change the branch to master and save.
wait for a pop up to tell you that you are life at a particular link.
copy the link, put it in the search area of your browser, hit enter and walaaa!! see you have push your resume to a git and is live.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/na1m1ey20i9tyimpgjxm.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nxkrb6hv27yjtlocurio.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/in7h835cjs2bgo6ii17c.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/afbm7pwvhxvew2w1sm83.png)