Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
January 11, 2022 05:17 am GMT

How to add your new project to GitHub in 10 easy steps

Okay, I am fairly new to GitHub. And initially, I used to struggle a lot with adding my local projects to GitHub.
I created a cheat sheet, so here it goes.

0. Pre-requisites:

Git on your local machine
Here is a neat article to help with that.

1. Create new repository on github.

Do not initialize .gitignore or readme at this point.

2. In your project root folder, create a .gitignore file.

In this file, add all the folder and the file extensions that you wouldn't want in the remote repository.
The following is an example .gitignore for a java project.

*.class# Mobile Tools for Java (J2ME).mtj.tmp/# Package Files #*.jar*.war*.ear# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xmlhs_err_pid*#folderslogs/target/#other*.classpath*.project*.settings*.pdf
3. Initialize local repo

In your local, navigate to the project folder from your favorite command prompt
git init -b main

4. Add all files from your project to your local

git add .

5. See the status of changes in local

git status

6. Commit to local

git commit -m "commit message"
On a side note, it's a great practice to keep committing to your local in small increments. That way, if you see that a code change is breaking and don't know which line did that, it's easy to revert back to a stable version.

7. Specify the remote repo for current local repo

git remote add origin https://github.com/username/repo

8. Add files from local to remote

git push origin main

9. Add a README.md file in github repo.
10. In case you want to update local from remote

git pull origin main

That's it, you did it :)


Original Link: https://dev.to/sanjbhat/add-your-project-to-github-in-10-easy-steps-4cl9

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To