Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about Git commands #6

Open
Ivurik opened this issue Oct 29, 2018 · 2 comments
Open

Question about Git commands #6

Ivurik opened this issue Oct 29, 2018 · 2 comments
Labels

Comments

@Ivurik
Copy link
Collaborator

Ivurik commented Oct 29, 2018

What are the GitHub commands we need to use to push our code to our GitHub repositories?

@ebeshero
Copy link
Collaborator

ebeshero commented Oct 29, 2018

Here's a survey of what to do to set up GitHub on your computer, as well as store, access, and push your files to your repository:

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/
    Your file directory may be spelled differently. Use your own spelling, then!

    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/ghbondar/webDevClass-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 webDevClass-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 webDevClass-Hub, I also check to see the directory name at the terminal prompt. Mine looks like this right now, and the key part is "webDevClass-Hub":
    gbg-wireless-pittnet-150-212-105-8:webDevClass-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 webDevClass-Hub repo at the top level
  • Then I type:
git add -A

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 webDevClass-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
Copy link
Collaborator

And if you ever don't know what to type, try:

git status

@ghbondar ghbondar added the HINT! label Nov 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants