![]() |
VOOZH | about |
We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.
Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.
Follow TNS on your favorite social media networks.
Become a TNS follower on LinkedIn.
Check out the latest featured and trending stories while you wait for your first TNS newsletter.
In the last installment on how to use the open source git version control software, we talked about setting up git on a late-model Linux notebook. We went over creating the directory for the files, initializing the git environment to track the files and how to put the files in a repository. All of the work was done on the Linux command line, within a standard terminal window.
In this installment, we’ll look at setting up a GitHub account on the Internet, how you send local content (repositories) up to your account and how to keep everything in sync. Although, I thought we might talk about the tree structure and analyzing commits, I’ll put that off to a later date. Getting the basic machinery working before starting to dig down into the finer points of using git will keep things at the proper level, right now.
We’ll end our discussion with a bit of how you get content out of GitHub and back down to your Linux notebook.
Git is inherently local. In other words, it will track your files and make snapshots of your work with or without a network connection or centralized storage. When you want to collaborate with others or bring in outside code, connecting to a git service is useful. One such git service is GitHub. Thinking in terms of a single user, GitHub is also a great way archive your work up in the cloud.
The service has a nice web-based interface, including a built-in text editor that you can use from your browser. Others, on the Web can also look at your project through kind of a “read-only” mode. I want to use GitHub to organize and promote my projects.
And in the software development world, the first thing a tech person wants to know is your GitHub address. Right?
Go to the GitHub main page and sign up as a new user.
With the account in place, we can now establish a new repository, on GitHub, for our project.
Choosing to build the readme, etc. files, at the beginning will make it confusing when you try to do your first push of the local repository on your Linux notebook up to your newly created GitHub repository on the network. GitHub will grumble about the synchronization of your files, before you’ve even tried to push any up. You can always add and edit the readme and other files later.
The new repository on GitHub should now be functional.
Before we can send anything from our Linux notebook repository up to GitHub, we have to get an authorization token. Authorization tokens took effect in August 2021. Before then, you could simply use a user name/password combination. Tokenized access is more secure and isn’t too hard to set up or use.
Go to the main GitHub screen, in your browser. The easiest way to do this is to type https://github.com/[your username] into the URL box. Likewise, if you are down in a repository for some reason, click the username directory level at the upper left-hand corner of the screen. In my case, it might be something like drtorq/bio. I’d select the drtorq part because that is my username.
The token will appear on the screen. You should carefully write it down for future use. You can also save the token as a text string somewhere. I copied mine to my desktop clipboard through Clipman. That way when I get to the spot where we need to use the token, I’ll just paste it into the correct place and hit enter.
Sending files up to the new GitHub repository is straightforward, once you have the initialization and token established correctly.
On the Linux command line, I executed the following.
drtorq-notebook% cd track-h
drtorq-notebook% git remote add origin https://github.com/drtorq/track-h.git
drtorq-notebook% git branch -M main
drtorq-notebook% git push -n origin main
The first line puts me into my track-h repository directory.
Next, the git remote command connects the web address of my newly created GitHub repository to a local (on the Linux notebook) repository reference or pointer, called “origin”.
If you want to change the branch name from the default, the git branch -M command will work. We had changed it when first setting up the account on the Linux notebook, so this one is optional.
Finally, I pushed the last commit of the repository up to GitHub with the git push command.
git push will ask for your user name, which in my case is drtorq@drtorq.com and then the password. Type or paste the token in place of the password. If everything worked right you should see a summary of the transaction, as in the figure below. Take a look at the summary. We’ll get into the specifics at another time. For now, this one just shows a successful push.
If you then go up to the repository on GitHub (in your browser) you can see that the current files there, reflect the changes made down on the local Linux notebook. For example, if I added a new line in text4.txt and then did the commit/push, the text4.txt file (on GitHub) will show the new line, upon clicking on the file in my browser window in the GitHub account.
Getting updates back down to the Linux laptop isn’t very much of a chore, either.
Assuming you are still in the track-h directory, down on the Linux notebook, it’s a simple matter of using the git pull command.
drtorq-notebook% git pull origin
The above figure shows file4.txt on the Linux notebook. I then edited the file on GitHub using their built-in browser-based editor and added a line. The bottom of the editor has a “commit” button that commits the file on the GitHub repository.
The middle part of the screenshot shows the git pull request.
Lastly, you see the file after the git pull confirming that the line was updated in the local file4.txt file.
This is a good stopping point for the second installment of our git learning series.
So far we’ve looked at setting up git on a Linux notebook and covered the basics of connecting our repository up on a git service, such as GitHub. That is a lot to digest and get straight in your head. You may want to peruse a couple of basic video tutorials for git.
Next time, I’ll delve into how I might put some of my real-world content into a repository and start to use git and GitHub to organize a project. It might also be nice to see how to pull down other people’s projects and use them locally on a Linux notebook. git makes tracking, organizing and sharing content pretty easy.
👁 A homebuilt Dr. Torq nameplate.
Contact Rob “drtorq” Reilly for consultation, speaking engagements and commissioned projects at doc@drtorq.com or 407-718-3274.