Skip to content

Instantly share code, notes, and snippets.

@ccannon94
Created September 11, 2017 01:43
Show Gist options
  • Save ccannon94/2a7fc760fd0b557181851bf9cef7fe65 to your computer and use it in GitHub Desktop.
Save ccannon94/2a7fc760fd0b557181851bf9cef7fe65 to your computer and use it in GitHub Desktop.

When you use git from the command line, use the following steps:

Accessing the Repository

  • On Windows, launch Git Bash, on MacOS or Linux, launch a terminal.
  • If you have not done so on your machine, create a directory to hold all of your git repositories. For a project this parge, it may be wise to use a directoy just for this project's repositories. You can create a directory using mkdir ~/Documents/aggie-autonomous-auto (or whatever you want to call your directory).
  • NOTE: This command only needs to be run once on each machine, to create the directory.
  • Navigate to your directory using cd ~/Documents/aggies-autonomous-auto.
  • If your repository already exists locally, navigate to it using cd [your-repository-name], if you want to check the contents of your directory, use ls.
  • If your repository does not exist locally, get the clone link from the "Clone or Download" button on the GitHub Repository. Clone or Download Button on GitHub
    • Then, clone your repository by using git clone [your-copied-url]
  • Once your repository has cloned, you must select it by changing directories: cd [your-repository-name]

Preparing the Repository

  • Now, make sure you are on the correct branch. You can check this branch using git branch and looking at which branch is marked with an asterisk.
  • NOTE: Updating the project from master
    • If you have worked on your project on multiple machines, it is a good idea to update from master before working. To do this, checkout master using git checkout master.
    • Now, make sure your master branch is up to date using git pull.
    • Checkout your working branch using git checkout [working-branch-name]
    • Make sure this branch is up to date with its remote self using git pull
    • Now, update your branch from master using git rebase master
    • You are now up to date and ready to work!
  • To create AND checkout a new working branch, use git checkout -b [working-branch-name]
  • Now, if your working branch is shown as your active branch, you're ready to get to work!

Working in the Repository

  • Open the code in Netbeans and begin working. Once you have made a single logical change to the code, it is time to make a commit!
  • Save your work in Netbeans before switching to your terminal
  • Now, stage your changes using git add .
  • Commit your changes using git commit -m "[your-commit-message]"
    • Type a brief (55 characters or less) description of the change you made. If you cannot summarize the change in 55 characters, you probably changed to much! Remember to use the imperative voice when writing commit messages, meaning say "Make change to the code" instead of "Made changes to the code".
    • Example: git commit -m "Create toString method in Student class"
  • Now that your commit is made, you should push these changes to the remote repository using git push
  • Repeat this process until your code is complete!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment