Working with the Git Worflow

Git is the most adopted version control system out there for software development. Git keeps track of changes made to a file over time and allows for access to those changes to anyone who has the link, unless you upgrade to a paid plan which allows you to have private access repositories. The workflow for using Git has three distinct steps: modifying files, staging those files and committing them. Let’s walk through the process of creating and modifying a file using Git.

I’ll assume you have used the Git tutorial to set up Git on your machine and have opened an account.

Create a practice directory and go into that directory in your terminal.

Image

Next, create a git repository in your directory with: git init

Image

Now we can create a file in the directory.

Image

That was our first step in the workflow, modifying files (in this case, creating a file)

Next, we can select this file or “stage” it to be added to our repository as an edit.

Image

At any time, you can find out the status of where you are in the Git workflow with the command: git status

Image

The above message, from git status, is telling us that we have a change to be committed and that the change is the a new file created called README.

At this point we have made the file, staged it and are now ready to commit it. To commit the file, we enter the command: git commit -m ‘a comment about the change that was made’

Image

 

The git commit command commits any changes that have been staged. There may be other changes that have not been staged yet, and those changes will not be committed until they are staged. This highlights the purpose of the staging part of the workflow. You may have changes that have been made but are not ready to commit, then you have to go to another file and make changes and commit them before the previous file you were working on is finished and ready to commit. Whichever changes you do want to commit, stage those files only, then commit them.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s