Skip to content

Instantly share code, notes, and snippets.

@ashleygwilliams
Created February 15, 2014 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashleygwilliams/9025167 to your computer and use it in GitHub Desktop.
Save ashleygwilliams/9025167 to your computer and use it in GitHub Desktop.

#Git Workflow 1:

Setup

  1. Create a project folder. This folder will contain all the files and folders for your repo
  • From a Mac or Linux terminal: Navigate to the path where you'd like to create the folder. Then type mkdir <folder_name>, replacing <folder_name> with whatever you'd like to name your folder.

You can also accomplish this from Finder or Windows Explorer.

  1. Initialize a Local Repository.

    • From terminal navigate inside the folder you just created. Use cd <path_to_folder>, replacing <path_to_folder> with the path to the folder you just made. If you are unsure, or have spaces or special characters in your folder names, use tab completion to make sure you use the correct path and names.
    • Type git init. If you have done this correctly you should see a message that says Initialized empty Git repository in...
  2. Create a Remote Repository.

  • Go to Github.com. Sign in if you need to.
  • Click the + button and select New Repository.
  • Give your repo a name, and initialize it as you see fit. Then click Create Repository.
  1. Link Local and Remote repositories.
  • In your terminal navigate to the folder where you have initialized a git repository.
  • Type git remote add origin <address_of_repo>, replacing <address_of_repo> with the HTTPS link on your new remote repo Github page.

-/-

Add, Commit, Pull/Push Cycle

(Repeat as many times as you need to)

  1. Add files. Build out files as you would normal do. Use git status to check in on what changes you've made. Then when you feel you've made the changes you would like to make type git add <file_name>, replacing <file_name> with the name of the file you'd like to add. If you want to add all the new and changed files you can type git add ..
  2. Commit changes. Once you've added all the files you'd like to add, commit your changes and add a commit message. Type git commit -m "<message>", replacing <message> with a description of what changes you are making, in the active, present tense.
  3. Pull from remote repo. Ensure that you have all changes that have occurred on the remote codebase by pulling. Type git pull origin master.
  4. Push to remote repo. Push all the changes you have just commited to the remote codebase. Type git push origin master.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment