Curriculum
Course: Git
Login
Text lesson

Push Branch to GitHub

Let’s create a new local branch and push it to GitHub.

Begin by creating a branch, as we did earlier.

git checkout -b update-readme

Switched to a new branch 'update-readme'

Next, make some changes to the README.md file by adding a new line.

Then, check the status of the current branch.

git status

We see that README.md has been modified but not yet added to the staging area.

git add README.md

Check the status of the branch.

git status

We are satisfied with our changes, so we will commit them to the branch.

git commit -m “Updated readme for GitHub Branches”

Now push the branch from your local Git repository to GitHub so everyone can see the changes.

Example

[user@localhost] $

git push origin update-readme
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
elta compression using up to 16 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 366 bytes | 366.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
remote:
remote: Create a pull request for ‘update-readme’ on GitHub by visiting:
remote:      https://github.com/code7school-test/hello-world/pull/new/update-readme
remote:
To https://github.com/code7school-test/hello-world.git
 * [new branch]      update-readme -> update-readme

Go to GitHub and verify that the repository now has the new branch.

On GitHub, you can now see the changes and merge them into the master branch if you approve them.

By clicking “Compare & pull request,” you can review the changes and any new files added.