Problem: You have code you want to share with others and you don’t know git…
Solution: Here are the basic steps to follow
1 Download and install Git
Git Page
Install Git on Win10 quick video
2 Navigate to the root folder of your project and create a file named .gitignore
Include inside it the folders and files that you do NOT want to share.
e.g.
node_modules
client/node_modules
config/default.json
private/my_secret_passwords.txt
3 Initiate a git repository by typing
git init
in the console
4 Stage all the files you are about to commit by typing
git add .
5 Make the commit
git commit -m 'YOUR_DESCRIPTIVE_MESSAGE'
YOUR_DESCRIPTIVE_MESSAGE is just informative text
So far you have commited your code to a local git repository.
Now you need to make it public, with a remote repository hosted in Github.
(There are alternatives to Github, such as Gitlab, Bitbucket and more but this is not the topic of this article…)
6 Sign up and sign in to Github: https://github.com/
7 From the top-right select the + sign , New Repository
8 Set a name for the new repository, e.g myrepo
9 In the next screen, copy the lines from the paragraph …or push an existing repository from the command line
git remote add origin https://github.com/stefaleon/myrepo.git
git branch -M main
git push -u origin main
10 Paste those lines in the console and enter
Now the contents of your project (except the .gitignore includes) are uploaded to a repository in Github which you can share via the url like
https://github.com/your_github_name/myrepo
After on, if you update your code you can be updating your local commits with
git add .
git commit -m 'YOUR_NEW_COMMIT_MESSAGE"
and also updating the remote copy of your repository in Github with
git push
Top comments (0)