Chris Jackson home

GIT Commands

GIT is a LINUX-based source control program. It uses a command prompt interface, and reminds me of UNIX commands for the university mainframe in the early 90’s.

Not only does source control allow for project collaboration between developers, it functions as a save point to which one can return if an experimental programming technique proves unsatisfactory. Basically, you make a real change to a program, go ahead and check it in before making the next. Under no case should you go for more than a day without checking in, and maybe twice a day might be smarter.

Some commands I’ve already encountered:


 

  • git init                                                                              Initializes GIT tracking for the directory & its subdirectories. Do this once per project.
  • git status                                                                         shows outstanding non-committed work.
  • git log --oneline                                                             shows a “friendly” version of the log. By itself, log looks like a dir or ls command.
  • git add .                                                                           add the current files tracked. Only tracked files can be checked in.
  • git c                                                    change focus to branch
  • git commit -a -m                               commits tracked work with as a title.
  • git checkout -b                                created a branch from which to make changes titled .
  • git checkout                                     change to .
  • git branch                                                                       List all branches. The current one will be highlighted.
  • git merge                                          merge into the current branch.
  • Git rebase Master                                                         grab changes from Master since the last rebase, then apply my changes to the current branch.

 

Thus, the correct method for safely updating your changes to the branch Master would be:

 

git add .

git commit -a -m

git rebase Master

git c Master

git merge

Fork me on GitHub