Search code examples
gitgithubgithub-for-mac

Commit Process Through Command Line - Repo Not Updating


I am learning how to use GitHub. I have it downloaded on my Mac desktop, and have an account online.

I created a practice folder on my computer 'test4' with one file in it called 'index4.html'.

Now when initialize git, I don't see the git folder created in my directory. When I commit changes, nothing is added to my github accounts. Here is my process via the command line, I think I am missing a step.

Terminal:

cd test4
git init
git add index4.html
git commit -m "comment"
git push origin master
git clone https://github.com/ibagha/test_test.git

There is nothing showing up in the repository I made. If anyone can let me know what I could be doing wrong, please let me know.


Solution

  • Git is a distributed version control system. This means you have a full copy of the repository on your computer and a separate full copy of the repository on Github. When you run git commit, you are committing to your local repository. You need to git push to send that change back to Github.

    You don't see the git folder after you initialize git because it is actually called .git and would be hidden by default on most operating systems. Try ls -a to show it. But you don't actually have to interact with that folder directly at all.

    Your commands are somewhat mixed up. You shouldn't need to do both git init and git clone. Also, git clone should be the first command you run. If you run git push before git clone, git won't know where to push your changes to (it doesn't know about the remote Github repository yet).

    Try this:

    cd new_test
    git clone https://github.com/ibagha/test_test.git ./
    echo "foobar" >> index4.html # Make a change
    git status # Not necessary - shows you what's up
    git add index4.html
    git status # Look what changed
    git commit -m "comment"
    git status # Look what changed
    git push # You only have one remote and one branch. Don't need to specify.
    

    Extra info:

    • To show all remotes, git remote
    • To show your branch (master) and the upstream remote it is tracking, run git branch -vv
    • You can make as many commits locally as you want before running git push. git push will send all the commits on your current branch to Github if Github doesn't already know about them, effectively "syncing" Github with your local repository.