Skip to content
This repository has been archived by the owner on Aug 22, 2020. It is now read-only.

How I work with Git and GitHub #497

Open
ebeshero opened this issue Aug 31, 2018 · 0 comments
Open

How I work with Git and GitHub #497

ebeshero opened this issue Aug 31, 2018 · 0 comments
Labels

Comments

@ebeshero
Copy link
Owner

ebeshero commented Aug 31, 2018

I switched from a PC to a Mac a while ago, and had to access my old GitHub repositories on a new computer. I cloned my repositories inside the Mac command line terminal, and I configured my GitHub account there, too, in a few careful but quick steps. Here's the Mac-specific documentation I followed, which is really close to what you'd do on a PC in the Git Bash shell. But I think this tutorial for Mac is better because it explains how to complete the installation. The git commands are ALL the same in both environments.

The key thing to me in working with GitHub is that I always need to know where to find my files in the Finder and in the Terminal. So I need to save them in a place where I can easily see them.

  • In the Finder, I just made myself a "GitHub" directory that lives inside "Documents." Inside the "GitHub" directory I clone each of my project repositories.
  • In the Mac Terminal (command line shell), I can navigate to my directory from my computer's root by typing:
    cd Documents/GitHub/
    cd means "change directories" and here I am stepping down into Documents and into GitHub. I usually pause there and take a look down at what I have inside, by typing ls (which means, list out what's inside this directory).
  • If I need to clone a repository, I do so here, because then the new repository will sit as a child inside my GitHub directory. I go to the git remote website and get its Download/Clone URL by copying it.
    Then I type git clone and paste in the the URL after that. so it looks like this for our DHClass-Hub:
git clone https://github.com/ebeshero/DHClass-Hub.git

I hit enter, and watch the lines scroll away in the command line terminal as the repository clones itself on my local computer inside my GitHub directory.

  1. I interact with my local directory the way I would any other. I drag files into it using the Finder. I save files into it. And I check in with the remote repository to pull new files in. So this is what I do:
    I open my Terminal, and I step down into my GitHub directory, and then down into the DHClass-Hub, and check that I am where I think that I am, by typing ls. The ls command shows me the contents of the directory in which I've positioned myself.
  • To make sure I'm in the right directory, the top level of the DHClass-Hub, I also check to see the directory name at the terminal prompt. Mine looks like this right now, and the key part is "DHClass-Hub":
    gbg-wireless-pittnet-150-212-105-8:DHClass-Hub ebb8$

Then to pull in any changes from the remote "mothership" repo, I type:

git pull
  1. When I want to share my local files with the remote mothership and my collaborators, I need to add, commit, and push those changes. Here's how I do it:
  • I make sure I'm in the DHClass-Hub repo at the top level
  • Then I type:
git add .

The period means all-- add all new files to be tracked by Git.

  • If I type git status at this point, I see highlighted the new files I'm going to add!
  • Now, I need to commit those changes. I type the commit, and write a message, because Git always makes me document my changes when I push to a remote "Mothership" repo:
git commit -m "I'm committing a picture of a llama to the DHClass-Hub Sandbox"
  • Next I push the commit through, with this:
git push

And gears turn and lines of text whirl on the screen, and my file goes up into the remote Mothership repo! I always check on the web repository to see if my commit went through.

That's how I do it.

@ebeshero ebeshero changed the title How we work with Git and GitHub How I work with Git and GitHub Aug 31, 2018
@ghbondar ghbondar added the hint label Sep 1, 2018
@ebeshero ebeshero closed this as completed Jan 7, 2019
@ebeshero ebeshero reopened this Aug 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants