Getting Git

A comprehensive video course from git init to Git Master.

init: git push

In this video we'll learn how to use git push.

When we talk about sharing our work we're really talking about sharing commits.

As we learned in Part 3, it's common to group work together on a branch.

So let's create a branch off master and make a new commit to add our name to the registry.

First, I'll create and checkout a branch called register.

Next, I'll append my GitHub username to the registry.txt but running:

echo jasonmccreary > registry.txt

If you don't know you're GitHub username, you can find it on your profile page.

I'll review my changes by running git add -p.

Then I'll commit these changes with a message of, "Signing the registry".

Now I want to share this work. Or more specifically, I want to publish this work to GitHub.

I can do so with git push.

git push takes a remote name followed by a local branch name.

So in this case if we want to push our work to our fork on GitHub, we would run:

git push origin register

From the output we can see that Git created a new branch on origin and pushed the commit.

If we go back to GitHub, we'll see it contains the registry branch with our commit.

As you make more commits, you can run git push again to share your work.

If you did work on another branch, you can simply change the branch name. And, provided you have access, you could change the remote name to share your work with another remote.

While this is the most common usage of git push, we'll learn some shorthands and additional scenarios in the Master video.