Basic Program Iteration Management Using Git

Git and Github are ways of keeping track of software changes over the course of its development. Git helps keep track of changes to a project on your local device. Github manages the project online, and allows multiple developers to work on the same files together.

Git

The basic flow of work while using Git is as follows:

  • You make changes to a project (your working directory)
  • You add the changed files to be committed (the staging area)
  • You commit these changes (and send them to the repository)

At first, it sounds like a complicated way to save things. Why not just change and save? For starters, Git keeps track of individual changes, and makes it possible to undo any changes made. Also, by using the staging area, you can make changes without actually committing them to the project. This is useful when functionality has not been completed, such as calls to variables or methods that have yet to be defined.

Basic use of Git (after it has been configured):

  • Using a command line, navigate to the directory where the project has its root. This folder should contain all the files needed for the project, and any subdirectories.
  • Type “git init” to start the process. (It is recommended to add a Readme to this directory.)
  • At any point, you can type “git status” to see which files with changes are in the staging area and which are not.
  • Make some changes to the files. Create files, delete files, modify files.
  • When files are ready, type “git add file_name” to add the files to the staging area. They will get ready to be committed, but they will not be done until you say so.
  • When you are ready to commit, type “git commit -m ‘Insert a commit message’ to commit the changes. Always add a descriptive message that explains the ‘why’ for the commit.
  • Repeat the process.
  • It is important to be in the correct directory (the same one in which you ran “git init”) for Git to function.

Github

In order to share code and entire projects, Github offers a project hosting service. Multiple developers can be working on a project, and can all update the same code. In order to do this, you:

  • Checkout the project
  • Make changes, add them to the staging area, and commit them as above
  • Push the commit to the Github repository

In order to do this, use these steps:

  • To link a directory on your device with a Github repository, you can visit github.com/new
  • Once created, make sure the SSH button is clicked near the top of the page, and click the clipboard button to copy the link.
  • While in the command line, in the directory which will be connected to the Github repository, paste the copied link. Press enter to connect the two.
  • Whenever you finish a commit and wish to make changes to the project on the Github repository, type “git push”.
Basic Program Iteration Management Using Git

Leave a comment