How to commit and push to Git.

Chance Cornell
3 min readJun 15, 2021

When using Git with your projects, there are three things that we need to do. Pull, Commit, Push. We will talk about how to do each of those next. If we continue to do these three things before attempting to upload, very rarely will we encounter a merge conflict.

Open up Git Bash in our project folder then type in

git pull *name of your remote server* *your branch name*

Your branch name is the blue word in parenthesis at the end of your command header. *It is possible that you may encounter an error in this area due to the branch name. The latest terminology is ‘main’ instead of the default ‘master’. This is something that can be changed inside your GitHub settings-> Repositories. Here you can change the name of the default branch to whatever you want.
for me, my command looks like

git pull origin master

This command will pull the files from the repository to your local project, making them up to date.

Now we’re ready to start committing our files and prepping them for upload. What we want to do now is type in

git status

This will show up files in red that need to be added to the repository. Our next step is to add them to a commit. To start the initial upload to GitHub we will want to add all the files in red. So to do that, we will type

git add .

This command will add all the files. If you type in ‘git status’ again, you will see all the files are now green. All those are ready to be committed.

To create a commit, we will type the following

git commit -m "insert commit message"

The commit keyword is what will make the command recognize that you are trying to commit some work to your repository. The -m is the message of what you did on this particular commit. Something like “created new unity project” is good for a first commit. After that, be detailed in what you did, so your team will know as well. The quotation marks are needed for this to work.

You will see all the files appear in white, this is what it will look like when all the files are added to the commit.

We should now be ready to push our commit to the GitHub repository. To do that we will type the following command.

git push *name of your remote server* *the branch you want to push*

In my case, it would be

git push origin master

You should after a couple of seconds see that your commit is being pushed to the GitHub server. You can now check your GitHub for that commit.

If your Git Bash freezes up and begins to give you fits you may have to create an SSH and upload that way. I created an article about that since I had that issue trying to upload using HTTPS. After switching to SSH, I’ve had no issues so far. *

That is it. You uploaded your first commit and all you have to remember after this is pull, commit, push.

--

--