I am going to list a few steps which would help you create a GitHub repo and perform basic tasks using this :
Git is an open sourced version control system, and “it’s responsible for all the stuff that’ GitHub related and happens locally on your computer”.
- Download and install the latest version of Git
- Setup git on your machine
- Set your username and email as follows, using a terminal:
Oh yes, you can skip all of the above steps and get the native GitHub app instead :
4. In the user at the top right of your GitHub page, click on create a new repo button.
5. Select the account you want to create the repo on.
6. Enter a name for the repository, and click on “Create repository”.
7. CD into your project
$ git init
10. Create a new file in the directory, say test.txt and then run git status command again. You will see that git says “untracked files present”
11. You need to inform Git to start tracking changes made to test.txt, and add it to the staging area by using:
$ git add test.txt
12. Now the files are in the staging area, but not yet in the Git repo. To store the changes we have made, we run the commit command with a comment describing what was changed:
$git commit -m “Added a test file”
13. To view a log of all commits:
$ git log
14. Now all the commits made are only to the local repository. How do we push it to the server, so that others can see/download it?
Consider the repository to be repo-test
$ git remote add origin https://github.com/username/repo-test.git
and finally push your changes to the server:
$ git push -u origin master
How about contributing to a new project or using somebody else’s code as a starting point for yours?
This is called forking a project, and can be done as follows: Let’s say you want to contribute to txtWeb-Wikipedia project:
16. Clone your fork to your local machine, so that all the code associated with this project is available on your local machine and you can modify it, using the following command:
$ git clone https://github.com/username/Wikipedia.git
17. Configure remotes:
In order to keep track of the original repo you forked from, you need to add another remote named upstream:
$ cd /path/to/your/wikipedia
$ git remote add upstream https://github.com/txtWeb/Wikipedia.git
$ git fetch upstream
You could also push commits to any repo using the following command:
$ git push origin master
18. A list of helpful links for learning other GitHub commands: