Adam Cap

  • About
  • Mail
  • Archive/Search

Use Git to Manage WordPress Projects Developed Locally on macOS

↗︎ Sep 30, 2019⇠ | skip ⇢

Git is a system for keeping track of changes in code. It’s particularly useful for collaboration (“Hello, world of fellow programmers!”) and reversion when a project’s source code has inadvertently ventured treacherously and irrevocably astray (fervently spamming CMD+Z is not always enough to re-establish baseline).

I obdurately refused to learn git for many years, because I am a doofus, and worked mostly solo on projects (verily to detriment). I recommend learning git, sharing code, and collaborating with others. Feedback is invaluable; you’ll get way better way faster than I did working this way.

Because I didn’t exactly hit the ground running, in terms of adapting git, I’ve typed out loose directions for personal reference—and for others whose interest is piqued and could use a guiding hand.

First: Initialize Git

  1. Install Xcode command line tools:
    open new Terminal tab/window
    xcode-select --install (or xcode-select --reset) (see: link)
  2. Go through seemingly pertinent GitHub setup guides: link
  3. Generate SSH key (and add passphrase to keychain): link
  4. Add SSH key to GitHub account: link

Second: Create Origin Repository

  1. Visit: link
  2. Choose repository name and public/private (skip other options)
  3. Create repository
  4. Leave succeeding page open (it lists helpful commands and SSH URL needed below)

Third: Initialize & Commit Remote Repository to Origin

  1. Navigate to local, top-level project directory (e.g., WordPress theme or root):
    open new Terminal window/tab
    cd [Local Path] (drag folder from Finder to Terminal to get path)
  2. Add remote repository:
    git init
    git remote add origin git@github.com:[GitHub Username]/[Repository Name].git
  3. (Pull remote repository:)
    git pull origin master (see: link)
  4. Create .gitignore file to ignore files in repository:
    touch .gitignore
    edit w/ text editor (see: link for guidance w/ file contents)
  5. Add files and commit changes:
    git add -A
    git commit -am "[Message]" (e.g., git commit -am "first commit")
  6. Push to remote repository:
    git push -u origin master

Misc. Maintenance

  • View status:
    git status
  • Remove .DS_Store:
    find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch (see: link)
    git add -A
    git commit -am "delete .DS_Store"
  • Remove remote repository:
    rm -rf .git
    rm .gitignore

Me

circa 1996 (9 y/o)

about adam

Recently…

  • 19 May 4: Prevent iOS + WordPress from Replacing Arrows (and Other HTML Symbols) with Emoji #CSS #HTML
  • 19 Mar 23: Move from Live Production Environment to Local macOS Development Sandbox (MAMP) #command line #WordPress
  • 19 Jan 30: Save Jetpack “Site Stats” Pageviews as Post Meta #JavaScript #PHP #WordPress
  • 19 Jan 26: Use Git to Manage WordPress Projects Developed Locally on macOS #command line #WordPress
  • 19 Jan 18: Fix Line Height for Input Placeholders in Safari #CSS
  • 19 Jan 18: Add Partner/Associates/Tracking ID/Tag to Amazon Links #PHP #regex #WordPress
  • 19 Jan 18: Add Fancybox Attribute to Image Links #PHP #regex #WordPress
  • 19 Jan 18: Automatically Bold (or Style) the First X Words of Content #PHP #regex #WordPress
  • 19 Jan 16: Move from Local macOS Development Sandbox (MAMP) to Live Production Environment #command line #WordPress
  • 19 Jan 15: Add Media/Attachment Source Fields (and Display Image Sources in Content) #PHP #regex #WordPress
  • 19 Jan 7: Remove Nonbreaking Spaces ( ’s) from Content and Text Widgets #PHP #WordPress
archive

More…
command line (Language) / WordPress (Tag) / code (Post Type)

⇠ Previous
Next code ⇢
  • Home
  • About
  • Archive
  • Mail
  • Random
  • Dingus
  • Reading
  • Code

ADAM CAP is an elastic waistband enthusiast, hammock admirer, and rare dingus collector hailing from Berwyn, Pennsylvania.

My main interests at this time include reading, walking, and learning how to do everything faster.

Psst: If you find my website helpful or enjoyable, please join my newsletter and/or send me an email—I want to hear from you!

Disclosure: As an Amazon Associate I earn from qualifying purchases.

© 2009–2023 Adam Cap(riola) top ⇡