newtfire / introDH-Hub

shared repo for DIGIT 100: Introduction to Digital Humanities class at Penn State Erie, The Behrend College
https://newtfire.github.io/introDH-Hub/
Creative Commons Zero v1.0 Universal
8 stars 4 forks source link

How I work with Git / GitHub on my computer #5

Closed ebeshero closed 3 years ago

ebeshero commented 4 years ago

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 is better for Mac users because it explains how to complete the installation.

The git commands are ALL the same in both Mac and Windows. There are little differences in the way your shell/terminal looks as you work with it.

The key thing to me in working with GitHub is that I always need to know where to find my files in the Finder (or Windows File Manager) and in the Terminal (or Windows Git Bash Shell). 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, following the steps below:

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 a web browser to open the remote website on GitHub 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 introDH-Hub:

git clone https://github.com/newtfire/introDH-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.

I interact with my local directory the way I would any other. I drag files into it using the Mac Finder (or Windows File Manager). 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 or Bash, and I step down into my GitHub directory, and then down into the introDH-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 introDH-Hub, I also check to see the directory name at the terminal prompt. In my Mac terminal, it looks like this right now, and the key part is "introDH-Hub":

eeb4@salamander introDH-Hub%

On my Windows computer this will look similar, but my prompt will just start with a $. This is just a prompt that your terminal gives you to signal it's ready for you to type in commands. Get used to how it appears on your computer.

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

git pull

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 .

or an alternative which is a little more powerful:

git add -A

The period, or the -A command, means all-- add all new files to be tracked by Git. git add -A is a variation which works if you've deleted files and you want to make sure your deletions get shared with the web repo.

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.

arrowarchive commented 3 years ago

@ebeshero I know this is an old issue, but it's likely that I may post a video on my repository soon. I know someone shared the code for how to embed a video into a GitHub page, but I don't know where it was posted. Would you happen to know what the code for it is?