Why learn Git hub as a programmer?
As a matter of fact, many recruiters in the field of programming or web development expect you as a programmer to use the new technology to sell your skills, for example, the recruiters expect to see your portfolio and not the paperwork, besides that you are also expected as a programmer to showcase the sample of the work you have done, and this forms the basis for learning Github.
Basics of Git hub
Git: This is software for tracking changes during a set of files with the aim of coordinating work among programmers working together developing ASCII text file during the software development process.
Github: it is a website and cloud-based service provider that allows programmers to store, manage and share source code.
Repository: It is a central place or a folder where programmers can store and manage their codes.
Fork: It means writing a second copy of the original code but with the aim of producing the same result and after it working you can now merge it to the original codebase. This applies especially when programmers are working as a community and they want to contribute to your source code though they cannot change your code and if their contributions are helpful you can now decide to merge or implement their code.
Pull request: This is a way developers can notify others in the team about the changes you have pushed to a branch in the repository on GitHub. This allows your teammates to review your code and discuss giving different suggestions if needed before the final copy can be merged to the base branch.
Git push: this is a time when you want to send your commits and ask them to update their branch
Version control: this is often the practice of tracking and managing changes to the code or the software.
How to push code to GitHub
There are two ways, one of it is by using GitHub desktop or git command line
Using command line
If you do not have a GitHub desktop and want to use the command line to commit your project to your git hub account, then you have to type in the browser github.com.It will direct you to the dashboard where you will see the green button to create the new repository.
Then on the same project page, you will click the green “Code” to display the URL that you will use to connect to that folder, copy the URL.
Connecting the local repository and the remote repository you will use:
$ git remote add origin
Pushing the changes you have made from the local repository to the new remote repository you will use this command:
$ git push origin master
1. Using the terminal or the command line you have to make sure that you are in the correct file where your project is.
2. use git status to check if git is initialized.
In case you encounter a mistake message: fatal: Not a git repository (or any of the parent directories): .git, meaning that the folder where your project isn't being tracked. To correct the error, type git init and then continue with the process of committing your project.
Also if other errors might appear, you can copy the error and paste it in google chrome to search.
Some Useful commands to note
Pull request using command line
This allows others to make changes to your project without interfering with the original work.
Here are some useful commands to learn:
1. git pull “remote name” “branch name”
2. git pull consists of both git fetch and git merge combined together.
3. git fetch: it takes the recent commits in the local repository
4. git merge: it merges the branch from a remote to a local branch
5. git checkout –b “branch name”: It helps in making a new branch with its name.
Using Git Hub desktop to push code
The first thing to do is to download the executable file for GitHub desktop and it is available for any operating system.
You need to sign up or create an account with GitHub as a prerequisite.
Quick set up to GitHub desktop
Click the button as shown below and a pop up will appear telling you to open GitHub desktop
Clone a repository on desktop
Cloning means a copy of a target repository
Using GitHub desktop, click the clone button to create a copy of the repository or simply a folder.
When a new folder is created in your local computer, another hidden directory is also created with the “.git” extension.
Copy all of your work to the cloned folder and that can include even the images and any other files.
Commit to master on Github Desktop
All the files you added to the cloned folder can be seen on the GitHub desktop. You can give a comment on the files that you want to submit
Image
Publish branch to GitHub
You can publish your files to the GitHub space by clicking the “publish branch” button.
Lastly, you can check if it has been successfully published.
0 Comments