GIT and GITHUB | Getting started in puppy
In response to @RyPuppy's request, I am writing this sort of tutorial here on usage of Git and Github. Though the w3schools' tutorial on the same topic is great, still there are some topics which may not directly apply to puppylinux. So this post will be dedicated to clarify those things, and will try to act as a starter to using git and github.
Overview-
What is git?
According to wikipedia-
Git is free and open source software for distributed version control: tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development. Its goals include speed, data integrity, and support for distributed, non-linear workflows (thousands of parallel branches running on different systems).
What is github?
According to wikipedia-
GitHub, Inc. is an Internet hosting service for software development and version control using Git. It provides the distributed version control of Git plus access control, bug tracking, software feature requests, task management, continuous integration, and wikis for every project.
What is git and github used for?
git and github can be used for the following purposes-
Manage projects
Upload your projects on internet, so that other members of your team can also work side-by-side on the project (can be done privately as well, i.e. no one else other than your team members will be able to see the code)
Make different branches and work on different issues side-by-side
How to install git?
git is usually part of devx.sfs of the puppylinux version you use.
devx.sfs is a sfs package, which can be loaded by just a click, contains most of the programs necessary for development, such as git, gcc, etc.. Each puppylinux version has its own devx.sfs. The devx.sfs of most of the puppylinux versions can be found here. For example- devx.sfs for fossapup64 9.5 is listed as devx_fossapup64_9.5.sfs
in the site. devx.sfs can also be found here.
So, git
does not need to be installed, rather the devx.sfs for your specific puppylinux version needs to be installed/loaded.
Do I need to install github as well?
Github is basically a site (github.com) which allows us to put our project/code on it. So not only there is no need for installing github, you cannot do so either.
What is a repository?
A repository refers to just a single directory ('directory' means a 'folder'), containing basically all the code, configurations and documentation files of a program, in which git is initialized, i.e. git is tracking changes in the directory. A repository could be of 2 types-
Local Repository- A repository which 'may or may not have uploaded to internet' (doesn't matter if its present on
github
or so or not), but is available on a user's computer.Remote Repository- It is most oftenly a repository which has been uploaded on the internet. It 'may or may not be present on a user's computer', but the repository which is found on the internet is called the remote-repository.
So, for example, see my ehdd (shameless self 'non-profitable' marketing ). It has been uploaded to github, so it is a 'remote-repository'. But, I also have 'copied' (in more formal terms- 'cloned') it to my own computer. So the repository which is on my own computer is a 'local-repo' (repositories are many a times called 'repos' in short). Both are directories, still the one found on my own computer is called 'local-repo', while the one which is not found on my own computer is called 'remote-repo'.
Getting Started-
Configuring git locally-
To get started with git, you will need to set few configurations and tell git about your name and email. To do this, enter in a terminal these commands (I am using foo
as user-name and foo@foobar.com
as email account (fake))-
[]Configure user name-
Code: Select all
git config --global user.name "foo"
[*]Configure user email (no authentication required)-
Code: Select all
git config --global user.email "foo@foobar.com"
(Note that you set these credentials as your own 'actual' credentials as these credentials should preferably be same as that which you'll use while signing up with Github
.)
Adding a github account-
To use git
with Github
, you'll need an account. For this, go to github.com and press the Sign up button on the top-right of the page. Follow the prompts you get to create your account. Note that it is preferable that you choose the same user-name and email as you typed into git
earlier.
Additional git setups-
While git
comes set-up to be used already, but for puppys few configurations might not work. You could always use-
Code: Select all
git config ...
to modify a configuration, or-
Code: Select all
git --global config ...
to perform a system-wide configuration.
Here 'system-wide' doesn't mean for modifications for 'every users'. Instead, here it refers to modifications for 'all repositories' of the user. If --global is not used, then only the current-repository's configuration will be changed (if there is any current repository, otherwise git will return error). Note that remote-repositories never contain git
configurations.
For example, while using git on fossapup64-9.5, I get errors saying pager not found
. I know what is pager (for examples- more or less commands), I know that it is a configuration error, so I would run-
Code: Select all
git config --global core.pager "/bin/more"
to configure git to use /bin/more
as the pager.
Note that even though all git configs can be found here, still you are 'not required' to know all of them. I also learnt about core.pager
after searching a bit on internet.
git repository related commands-
w3schools's tutorial on these subjects is pretty good. I recommend that you follow the tutorial from here after (except for a single thing. Keep reading on).
The thing that w3schools doesn't point out-
w3schools' tutorial, though pretty good, still has a flaw. It doesn't point out that authentication now might not be achieved just by the use of a user password (Github has changed its policies, read this if you're interested reading the official statement), but instead tokens are introduced. Read the following guide to create and use your own tokens-
Creating tokens-
Go to github.com. Make sure you are logged into your account.
Click on your profile icon on the top-right. Now click on Settings.
Scroll down the page and click on Developer settings (found on the bottom-left of the page)-
Click on Personal access tokens in the window that opened. This will make few options appear. Now click on Tokens (classic)-
(Note that it is not advised to generate tokens which never expire. DO NOT FOLLOW ME!!!)From here, you can generate a new token. Do remember to copy the token down to somewhere you trust, as this token next time will not be visible (I mean the real 'token' will not be visible, just an entry that 'it is a token' will be visible on the same site).
Read this page for more info.
Using created tokens for git authentication-
When you push to a remote-repo, you'd be prompted for your username and your password. Enter your github username in the username
prompt, and your generated github token as your password
. If the generated token did not have 'write-access' to repositories, so this process might fail.
I am tired writing credentials again and again!
Look at viewtopic.php?p=71994#p71994 or viewtopic.php?p=72014#p72014 if you feel the same !
Final Notes-
That was it from my side. If you want clarification of anything related to git/github or if you see that there could've been some more things included in this post, then please reply to the post, your views are respected (and accepted).
Also, if you want to go deep into the subject, then you may even read git documentation and Github documentation, though I myself have not read them .
Helpful posts on this thread-
Since this thread was filled with many off-topic messages, I am pointing the links for useful replies in this thread that can be helpful:
-
The reason why GITHUB is the biggest and the most used platform for GIT
-
Odin project - A good open source online resource for learning GIT (and other sorts of coding)
And, that's all! If any of the above links are of your interest, click'em right away!
Regards
Lakshay