You can easily do a Git push — Github Tricks #1

Bayram EKER
2 min readJul 9, 2022

--

Step 1:

Initialize Git:

$ touch README.md    # To create a README file for the repository
$ git init # Initiates an empty git repository

Adds all the files in the local repository and stages them for commit

git add <filename>
git add *

Command to add files to staging area

git status # Lists all new or modified files to be committed

Step 2:

is a command used to add all files that are staged to the local repository.

git commit -m "Commit message"

Uncommit Changes you just made to your Git Repo:

$ git reset HEAD~1
# Remove the most recent commit
# Commit again!

Step 3:

is a command used to add all committed files in the local repository to the remote repository. So in the remote repository, all files and changes will be visible to anyone with access to the remote repository.

git push origin master

Now the git push command pushes the changes in your local repository up to the remote repository you specified as the origin.

Step 4:

If you have not cloned an existing repository and want to connect your repository to a remote server, you need to add it with

git remote add origin <remote_repository_URL>

Now you are able to push your changes to the selected remote server

Extra 1:

See the Changes you made to your file:

$ git diff # To show the files changes not yet staged

Revert back to the last committed version to the Git Repo:

$ git checkout .

OR for a specific file

$ git checkout -- <filename>

View Commit History:

$ git log

Summary

$ git add .
$ git status # Lists all new or modified files to be committed
$ git commit -m "Second commit"
$ git push -u origin master

--

--

No responses yet