GitHub commands

GitHub is a Git repository hosting service, but it adds many of its own features. While Git is a command line tool, GitHub provides a Web-based graphical interface. It also provides access control and several collaboration features, such as a wikis and basic task management tools for every project
So Here are some commands and why are they used:
- Initialise the local directory as Git repository.
git init
2. Add all the files in the local directory to staging using the command below.
git add .
3. You can now commit the staged files using the command below.
git commit -m "First commit Message"
4 .Now we will add the copied URL for your GitHub repository as remote repository using the code below.
git remote add origin https://github.com/yourusername/your-repo-name.git
5. use the below command line in your terminal to push the local repository to GitHub. It will upload the file or project on github.
git push origin master
6. To reinitialize a repo locally
rm -rf .git
7. To know the branches in a repository locally
git branch
8.To switch between the branches locally
git checkout branch_name
9. to create a new branch locally
git checkout -b branch_name
10. To remove a folder locally
git rm -r folder-name
11 . For pushing a branch to remote git
git push origin branch_name
12 . For deleting a branch locally
git branch -d branch_name
13. Deleting a branch remotely
git push origin :branch_name
14. Cloning the github branch
git clone -b <branch> <remote_repo>
eg: git clone -b dev https://github.com/username/project.gi
15. If you have forked a repo and made a PR once and it is accepted and want to make another one you will need to update the code in your local with the remote one so for that follow these steps
git remote add upstream https://github.com/whoever/whatever.gitgit fetch upstreamgit checkout mastergit rebase upstream/master
For creating a new repository follow
STEPS- 1 -> 2 -> 3 -> 4 -> 5
For deleting a folder in remote git
STEPS- 8 -> 10 -> 3 -> 5
For deleting a branch
STEPS- SWITCH TO MASTER BRANCH-> 12 -> 13
