...

Open source softwares - GIT

Back to Course

Lesson Description


Lession - #1160 GITHub Branch Push


Push a Branch to GitHub
Let's try to create a new local branch, and push that to GitHub.

Start by creating a branch, like we did earlier:


git checkout -b update-readme
Switched to a new branch 'update-readme'
And we create some changes to the README.md file. simply add a new line.


So currently we check the status of the current branch.


git status
On branch update-readme
Changes not staged for commit:
(use "git add ..." to update what's going to be committed>
(use "git restore ..." to discard changes in working directory>
modified: README.md


no changes added to commit (use "git add" and/or "git commit -a">
We see that README.md is changed but not added to the Staging Environment: git add README.md

Check the status of the branch:

git status
On branch update-readme
Changes to be committed:
(use "git restore --staged ..." to unstage>
modified: README.md


We ar happy with our changes. thus we'll commit them to the branch:


git commit -m "Updated readme for GitHub Branches"
[update-readme 836e5bf] Updated readme for GitHub Branches
one file modified, 1 insertion(+>


Now push the branch from our local git repository, to GitHub, wherever everybody will see the changes:



git push origin update-readme
Enumerating objects: five, done.
Counting objects: 100% (5/5>
, done. Delta 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 zero remote: resolving deltas: 100% (2/2>
, completed with two local objects. remote: remote: create a pull request for 'update-readme' on GitHub by visiting: remote: https://github.com/w3schools-test/hello-world/pull/new/update-readme remote: To https://github.com/w3schools-test/hello-world.git * [new branch] update-readme -> update-readme


Go to GitHub, and make sure that the repository has a new branch: