Trying to Understand Git

I don’t have a good understanding of how git works despite having installed it on my system and having created at least one repo; so I have some questions that I haven’t found answers to by searching. In the pages I’ve found and read, the scope of most of the articles confused me instead of laser focusing on a 1-2-3 approach to what I needss to know. I’m sure it’s my fault, not those who wrote those articles. I’m 83 yo and a retired IT exec who first wrote code for mainframes (COBOL/BAL) back in the '60s and '70s.

  1. It’s my understanding that Git is an app that resides on my computer and is accessed via a Windows PowerShell terminal, and that GitHub is a remote app accessed from a browser, eg, Chrome, at https://github.com. I have been to GitHub and created an account and even created a remote repo; however that was a couple years ago and I’ve slept too many times since then. I deleted that github repo so I can start again fresh with an active project.
  2. It’s my understanding that after creating the local repo that I can then move it to a github repo. That is my ultimate goal. This process will, hopefully, help me to become more accustomed to using both git and github. By having a public git hub repo, I can reference it when I post questions here instead of copying and pasting code in posts which clutters them up.
  3. I have executed a git init command on my system after having changed the directory path to where my project resides: G:/BiographyTest/ which has folders for /Images, /Scripts, /Styles, and /Thumbnails and an HTML file, testingstyles.html. The /Scripts folder is empty for now but will contain javascript in future as I continue to work on the project. The /Thumbnails folder will contain images that are coded to be clickable as links, but that is anticipating future development. I used separate folders for images and thumbnails simply as an organizational matter.
  4. My project currently contains the HTML file and CSS files that are external to the HTML. To date, there is one page that will be part of a website. Actually I have a website hosted, but it is crude, consisting only of HTML, CSS and a few images but no javascript or any other code to make it interactive. It can be viewed at https://rhhutchins.com/. My current project, BiographyTest, is reworking just a part of that site. Now that I have the page displaying as I want it to look, I plan to move forward with my javascript to make it interactive.
  5. After executing the git init I executed a git add . command. I think that was supposed to set up my project to be committed then pushed to the local repo. I don’t know enough about git (yet) to confirm or refute that supposition. Is there any way I can tell exactly what the local git add . command created? I’ve looked at git help and searched online but haven’t found an answer to that question.
  6. I need to know how to proceed from here. If my understanding of the process is wrong, I need to overcome the misunderstandings. If the git-to-github understanding is correct, I need to know how to get my local repo set up THEN I’ll need to know how to move it to the public repo at git hub.

I’ll try not to be too needy and will be most grateful for any and all help.

Thank you.

1 Like

run git status and it will tell you which files were ‘staged’.

Are you using any online resource to learn about git? (which one?)

I prefer myself to create the repo on Github first then clone it on my computer (that’s the workflow that is easiest to me).

1 Like

Thanks for responding, hbar1st.

First, I need to report that I have set up a local repo and I have added, committed, and pushed it to GitHub since my op. The first hurdle is past.

The GitHub repo is public,under my username, RHH42 and is named BiographyTest-Project. So far I have not updated the remote repo. I’m learning 1 step at a time, slowly.

I am using Simon Bao’s YouTube tutorials on Git and GitHub. As I mentioned in the OP, I had a GitHub account set up from a couple years ago. If you go to my GH repo, you will see several different repos there from the past. None of them has been kept up to date. I intend to keep BiographyTest-Project up to date as I make changes so that I can refer to it in posts here when I ask for help.

I intend to use version numbers when adding new functionality such as new pages or significant features along with release numbers for changes to existing code. For example, what I have in GH now is BiographyTest-Project, Version 1. When I update it with the first set of changes I will use Ver 1; Rel 1 (following software publisher traditions). Is there a better approach that you would recommend?

Can you, please, see if you can access my GH repo? If so, please tell me what directories you see and if you see the various /Styles files. Is the repo in order, fit for use as described?

Again, thank you for responding.

tia

I would suggest to go through below crash course on GitHub, Git from FCC and makes notes + do dummy project along as well to understand and be comfortable

  • one more suggestion, don’t try to use any of the clients for github but instead try to do through command line itself so that you will remember commands properly

  • Many senior developers prefer to use external GUI Clients, but don’t jump to it yet ( Google : github GUI clients )

1 Like

Thank you, Vikramvi.

I am using the Windows PowerShell to enter Git commands and I am trying to avoid shortcuts and mnemonics so that I will learn the commands.

I’ll take a look at the video you suggested. I think you recommended it to me a couple of years ago and I followed it. I am using the Simon Bao tutorial because I have taken others of his and like his teaching stlye.

1 Like

Also try using “Flashcards” to remember commands and maintain a xls sheet in Google doc about commands and what it does, also for any other GH issues, error & solution to it

These techniques helped me when I started using Git first time in 2014

1 Like

Git is a version control system, it’s both on your computer and on github

you can see it for yourself: GitHub - RHH42/BiographyTest-Project: Repo for sharing when posting there is only the readme file, it looks like you did not do any pushing after the initial setting

git add . adds any new or changed file in the current folder to staging, if you want to add all new files use git add *
after you do git add, you need to do git commit, then if the remote repo is set up correctly you can do git push to add your files to the remote repo

1 Like

Thanks, ILM.

The reason that I asked if you could see my GH repo was to discover if I had set it up as public repository correctly. I know that I can see it but want to know if others can. My confusion comes from the section GwenF covered about passkeys in her video. Do I have to set up a public passkey for others to see my code?

Vikramvi, can you tell me more about ‘flashcards’ you mentioned? If I understood you it was an xls file you created. Do you have an example you can share?

no, if we can see the repo we can see all the repo. The issue is that you have not added files to the repo

1 Like

Thanks. I didn’t confirm it (lesson learned), but I thought that I had pushed my repo to GH. I even experienced the Windows log in screen appearance.

Now, I’m trying to push it to GH but it’s not working. Here’s a ss of my terminal:
git push 1332hrs

When I go to GitHub - RHH42/BiographyTest-Project at master I see this:

I don’t understand what’s going on. Can you not see what I see at GitHub - RHH42/BiographyTest-Project at master? If you do, can you view the code in the files?

I was looking at your main branch, that’s the mistery! on github the default branch is main, so that’s what’s shown when I go there

In the master branch I see the files in the screenshot

1 Like

I recommend understanding Git itself without involving the Github part. You don’t need Github to run Git on your local computer. I use Git to track my own changes at work. I don’t push up any changes to Github because my employer does not use Github.

I recommend reading the Pro Git book. I went through the first three chapters to understand how to use Git on my computer. You can read the other chapters as needed.

You can download the pdf, epub, or mobi version of the book here: https://git-scm.com/book/en/v2

1 Like

I agree that learning git is a primary goal. I fully intend to master the subject. I only included GitHub in that goal because I want to be able to create public repositories that people can refer to when I ask questions, here and on other forums, about my code.

Many questions can only be answered by seeing the totality of the HTML/CSS/Javascipt/ . . . code. Having to include code in forum posts clutters them, but including a link to a public repo does not.

May I ask? Do you use git or git bash? Why choose either (or any other interface for git commands)? I’ve found Windows Powershell git to be a bit cluttered while using git bash provides some degree of clarity and ease of use.

Your question, “Do you use git or git bash?” indicate to me you do not grasp the fundamentals of what git is. Read the Pro Git book. Use the commands you learn about in the book in Git BASH.

Read and do. Learn by doing. That will help you understand the fundamentals. Use git on your computer only to start.

I asked Microsoft Copilot what the difference is between Git and Git BASH. It did a decent job explaining the difference.

Sure! Here’s a breakdown of the differences between Git and Git Bash:

Git

  • Version Control System: Git is a distributed version control system used to track changes in source code during software development. It allows multiple developers to work on a project simultaneously without interfering with each other’s work.
  • Core Functionality: Git manages and stores versions of projects, enabling you to revert to previous states, collaborate with others, and maintain a history of changes.
  • Cross-Platform: Git can be used on various operating systems, including Windows, macOS, and Linux.

Git Bash

  • Terminal Emulator: Git Bash is a terminal emulator for Windows that provides an emulation layer for a Git command line experience. It includes a Bash shell, which is a Unix shell and command language.
  • Command Line Interface: Git Bash allows users to run Git commands in a command line interface, similar to how they would on a Unix-based system. It provides a more familiar environment for developers who are used to Unix-like systems.
  • Additional Tools: Git Bash includes various Unix command-line tools, such as ssh, scp, cat, and find, which are not typically available in the default Windows command prompt[1][2].

In summary, Git is the version control system itself, while Git Bash is a tool that provides a Unix-like command line interface for using Git on Windows.

Do you have any specific questions about using Git or Git Bash?

References

[1] The Difference Between GIT, GIT Bash & Git Hub - DEV Community

[2] Git bash: Definition, commands, & getting started | Atlassian

1 Like

Excellent response . . . far better than my question.

One benefit of Git Bash is that unlike PS it shows the current branch you are on in the terminal, which can definitely save you from some headaches.

But PS is pretty good these days, they have added a bunch of *nix commands alias or equivalences as well so ls is just an alias for dir, but pwd is a fancier version of cd.

BTW, I personally do not mind this. But we do try to limit AI responses to questions in the forum. In this case, I think it is fine as it is likely correct, and you disclosed it as well.

Just a heads-up.

Limiting AI responses to questions on the forum makes sense. We don’t want every response on the forum to be a copy and paste from an AI tool.

Is this rule documented somewhere on the forum?

Thanks.

I don’t actually see it in the TOS, but it probably should be, considering we often have to advise people not to post AI responses.

Not really sure how we govern it or what the rules are, if not written anywhere. But we do strive to avoid AI responses in general. They are often very impersonal, and it can be harder to vet all the information an AI spews as part of what should be a simple response.

1 Like