Git Commands for pushing Files from local to remote repository

Git Commands for pushing Files from local to remote repository

1. Open Gitbash terminal

After opening gitbash you need to move to the folder/location where your files are located .you can change the directory by using the following command:

cd directory_name

2. Initializing empty git repository

After changing to the required folder/directory, now initialize the empty git repository.You can do this by the following command:

git init

after using this command a ".git" folder is created in your directory.

3.Configuring user information

Now you need to configure your info. set a name that is identifiable for credit when reviewing versions history. you can do this by the following command:

git config --global user.name "[firstname lastname]"

now set an email address that will be associated with each history marker.

git config --global user.email "[valid-email]"

you can also set automatic command line coloring for git for easy reviewing

git config --global color.ui.auto

4.Add a remote address

You need to add your remote repository URL i.e., from GitHub.You can do this by the following command:

git remote add origin repo_URL

5.Files status

  • You can track the status of your files.You can use the following command:
git status
  • after using this if the color of the files is red, it means there are "no commits".So you need to commit them, which can be done by:
git add .
  • again after using the "git status" command you can see that the color of the files becomes green. Now you need to commit your files by
git commit -m "msg"

6.Push the commits

You can push your commits by using the following command:

git push --set-upstream origin master

After following all these steps your files will be pushed onto your remote repository.

You can verify it by opening your GitHub account.

ย