Techtrekking

How to push changes from local repository to Github

By Pravin

Before pushing the changes, it is good idea to review the changes, this can be done using below command To check the list of files changed

git status

To see the detailed of each change in these files

git diff

use CTR+z to exit the diff details.

Before pushing the changes, always verify the remote git repository name to ensure you are not pushing to incorrect location.

git remote -v

Step#1 stage

First we need to stage changes by using git add command to include the changes in the commit If you want to push only specific file, use below

git add <file_name>

If you want to stage all changes in the current directory then use following

git add .

Step#2 commit

Now once the changes are staged, we need to commit changes. While doing commit, please create a commit with a descriptive message using the git commit command:

git commit -m "Your commit message here"

Step#3 push

To push the committed changes to the remote repository use following git

git push origin <branch_name>

Here replace <branch_name> with the name of the branch you're working on. If you're pushing to the main branch, you can usually omit the branch name

Comments
No comments yet. Be the first to comment!
Leave a Comment
Your comment will be visible after approval.