Don't understand GitHub—ready to give up

Well you have local repo(your computer folder) and you push content of said folder to you online repo on github. You can also take content from other’s people repos, create your copy of it on github, then sync i.e make a copy on the local. Imagine github as google drive who tracks what is modified inside of any file inside repos. example: If you erased line of code in your file, then commited that change to your local repo, after that you pushed it to github and you realized you made mistake. You can reverse state before mistake by pulling back files from you online repo by targeting particular commit. Check one of my repo’s out and here’s how it looks on pages.

1 Like

Oh, so the interface I’ve been working with on GitHub is the local copy, and we’re pushing that content to appear online. OK. Duh. I’m starting to get what should be totally obvious. God help me if any future employer ever reads this post. :frowning:

Unfortunately, now that I’ve deleted my repos several times, my computer is getting confused—it’s trying to authenticate a new repo using the name of an old one. Maybe I should pick a new name.

One more stupid question: How do you save your work without committing? Is that what branches are for? Build everything in a branch and then use a pull request to merge the branch with the main repo? Thanks for your help.

If you’re afraid of work being lost, you don’t have to be. Each time you commit, there’s a timestamp that allows you to know when the file was saved. It’s also why it’s important to save with comments so you’ll know which save is the last stable set or what changes were made and so on.

That being said, you can just save locally (you’re usual ctrl+s). Committing means that it’s, how to say, saved in a more lasting manner and logged with Git’s logs.

At least, that’s my understanding. Anybody can correct me on this.

2 Likes

Take it easy.

Everytime you create a new project on your local PC, you first create a folder on your PC, let’s name it my-project. You can store as many data inside it. This is an ordinary folder just like every person has many folders on his/her PC. Nothing special.

If you now git init it, git creates an invisible folder in the folder my-project.
From then on, git tracks all you changes in this folder. Invisibly, in the background.
This folder is now called a repo, because it’s a ordinary folder + git.

Now you did some work in this folder, e.g. changing index.html or copying an image into it and you say “Hey, I want to make a Snapshot of the exact, current state!”. You do this, because perhaps later you want to come back to this old state or send the current state to another person.

Then you use git add to select the files, you want to add to this current snapshot. Maybe you have a todo-list in this folder, that other people should not see.

Then you use git commit to say “Okay, I’ve selected the correct files and I want to close this snapshot”.

After a while, you will have many of this snapshots (commits in git language). You can see them with git log.

Now you load your page and damn, it’s broke. You made a mistake, and want to undo it.
No problem, because you have this old snapshots/commits of your work, you can easily go back in time.

That’s what Git is all about.

Now there is Github. So let’s assume, that you made all your small snapshots/commits on your local pc, but your pc gets stolen or it gets broken and your data is lost. Therefore we should have an opportunity to upload your local repo to an online hoster.

The only thing left to do is to setup a repo online on Github and link the local repo and the online repo.
Then you can send your local repo to github via git push or can get the online repo to your pc git pull or git clone etc.

Here you can see a simplified workflow:
Diagram

5 Likes

Holy mackerel! Would you believe I get this? So if I understand it correctly, when I delete a repository on GitHub, it’s still hanging out as a git in my local directory unless I somehow pull in the deletion? Thanks so much.

A while back I grabbed some links to various project by fCC users that were intended for people to work on projects while getting familiar with GitHub… links below:

1 Like

Correct. If you push it once, it is on your Local Machine and on Github.
If you delete it on Github, but have it on your Local Machine,
you can push it again to Github in a new repo.

And vice versa, if you delete it on your local machine,
but pushed it before to Github, you can clone or pull it from Github.

Try to practice for a while. You will recognize,
that you are using a few commands very often.
Make sure you’re safe with them.

2 Likes

Try to practice for a while. You will recognize,
that you are using a few commands very often.
Make sure you’re safe with them.

Got it. I’ll go with the “sacrificial lamb” idea and practice a bit before I charge ahead with blog posts. You guys rock. Thanks, @miku86, @alpino, @codename11, @ArielLeslie, @zapcannon99, and @DarrenfJ!


The above reply was meant for @miku86.

Thank you, @DarrenfJ, for the links. Right now I’m too dangerous to contribute, but in a couple of weeks I’ll revisit the projects to see if I’m ready.

Despite the subject line (“ready to give up”), I tend to be doggedly persistent at figuring things out. Even though I’ve been in a deadlock these past 3 days, I’ve learned so much by reading the explanations here, visiting the links, and mudwrestling with GitHub. :grimacing:

4 Likes

Nice summary! Though, I think you have an infinite loop in #4 :wink:

“4. Go into the folder of the project, you want to use with Git (by using the commands you learned in Step 4)”

1 Like

Don’t worry, there’s no such thing as ‘too dangerous to contribute’. Most projects operate on a ‘pull request’ basis (you mention PRs above, so it sounds like you already understand the concept), which means that there’s never any danger of you directly messing up the master branch’s code.

There’s usually someone else reviewing the PR you’ve made, and they’ll make the merge when they’re happy it’s safe and does what your commit message says it does. Unless it’s a one-person project, it’s generally best practise to avoid merging your own PRs :slight_smile:

1 Like

Hi @MelissaJayne, I can recommend you GitHub Desktop, which is a user interface for Git based version control. Sounds GitHub specific, but you can use it with any Git repository.
I think the older version has a better user interface. So I can recommend using the old one just because of that.

They also have a really short and to the point guide here: Understanding the GitHub Flow. I am sure you could find similarly good explainer videos on YouTube.

You can find other useful guides here like Hello World and Getting Started with GitHub Pages.

1 Like

I think you should hope an employer does read this post. They would see that you had a problem. You tried plenty of ways to solve it yourself including asking for help on an appropriate forum. You collated all the I formation you were offered and did some more research and solved your problem. I’d say most employers would love to see that kind of initiative in an employee! :smile::+1:

1 Like

Not sure if you already got how git work.
I suggest you try out gitkraken. https://www.gitkraken.com/ it is free for non-commercial use. This is the easiest git UI imo.
and some basic command you will learn.

git clone
git add -A
git commit -m “<your message for this commit, usually some short summary of what you did on this change>”
git push
git pull

There are some little more annoying one but important that i suggest you try out desktop app like gitkraken or source tree first.

git checkout -b

Check out the term “gitignore” it really save your ass as you working on different framework like Node, Unity and such.
You can check version of your git .

git --version

you can see if your folder is the root of git by open finder and go to your finder. Make sure that you can see hidden file/folder by command+j . you will see a folder “.git” in there.
Git can work local, totally fine. but it better to store it some where online so you can easy to share and work on different computer that need. that why we have service like gitlab, github, bitbucket…

2 Likes

Hi Melissa, when I got my first job I was told to do this exercises, then I knew more git than most people in the office, strongly recommend sparing some time for it.

3 Likes

Wow, I’ve managed to stay away from Git because I wasn’t super clear on what it was and figured I’d “figure it out later”. This was very enlightening, thanks!

1 Like

So kind! Thank you for the encouragement. It really helped. :relaxed:

Definitely will do this tomorrow. Thanks so much!

Hi again, everyone~

I had to step away for a few days to do some work (the paying kind), and I was surprised to find seven new replies to this topic yesterday. I can’t tell you how humbling and heartening and reassuring it is to receive all this support! Posters like @jerriais and @monotone2k have gone out of their way to make me feel like I can do this. I’ve been attending local tech Meetups, too, and the people there have been just as welcoming, not to mention smart and interesting.

Now I’m back in GitHub, and I have a workable blog format—feel free to take a look). (And if anyone knows why my profile block won’t float at the top right, please enlighten me!) My blog content is still in a Word doc, but I have >45 days’ worth of entries to load. I ended up using GitHub and the command line only. The other interfaces I tried just seemed to add an extra layer of complexity. I did go through all the tutorials except the one suggested yesterday by @Jamesfh. I’ll do that one next—it looks really helpful.

I know I’m doing some things wrong, such as committing too often and reviewing my own pull requests (like proofreading my own writing, right?), but it’s a small victory just to get something on the screen. This little GitHub detour has also been good practice with HTML and CSS. That might make things easier when I return to the Javascript certificate.

This topic has received >600 views already, so no doubt the resources suggested here will benefit many newbies like me in the future!

1 Like

I’ve been practicing with the command line, but these commands are new to me. I’ll play around with them. Thank you!

Thanks for the links. The tip about giving your branches descriptive names is really important.