Git Push To GitHub
Git Push
git push uploads all local branch commits to the corresponding remote branch.
The general form of the command is this:
What does git push do?
git push updates the remote branch from local commits. It is one of the four commands in Git that prompts changes/interaction in the remote repository.
When you made changes into your local repository, it only affects the branch that you are currently working with. That is why it is a good practice to git status to check what specific branch you are on before pushing to the remote.
For example, if your current branch is master, the command git push will supply the two default parameters—effectively running: git push origin master .
In the example below, I'm going to push local commits to the remote branch. But first I have to check what branch I'm currenly on using git status:
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: documentation-css/git-documentation.css
modified: documentation/git-started.html
modified: documentation/github-intro.html
Untracked files:
(use "git add <file>..." to include in what will be committed)
documentation/git-pull-from-github.html
images/push-local-repository-github.png
Now, we can see what branch we are on and the changes I have made in my local repository. Next is I'm going to add those changes and commit:
$ git commit -m "added git-pull tutorial module"
[master 7b320b1] added git-pull tutorial module
5 files changed, 403 insertions(+), 4 deletions(-)
create mode 100644 documentation/git-pull-from-github.html
create mode 100644 images/push-local-repository-github.png
and check status again:
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
Now it's ready to push changes to our remote origin:
Enumerating objects: 17, done.
Counting objects: 100% (17/17), done.
Delta compression using up to 8 threads
Compressing objects: 100% (9/9), done.
Writing objects: 100% (10/10), 155.59 KiB | 9.72 MiB/s, done.
Total 10 (delta 7), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (7/7), completed with 6 local objects.
remote: This repository moved. Please use the new location:
remote: https://github.com/LightLotus/tasty-git.git
To https://github.com/LightLotus/css-tasty.git
05ea34a..7b320b1 master -> master
Go to GitHub, and confirm that the repository has a new commit.