Home > Blockchain >  How to add code files in my github repositiry?
How to add code files in my github repositiry?

Time:07-05

I am new to GitHub and I really need help in adding my code files there. Recently my files went missing in vs code and hence I want to save my files before it is gone. Thanks!

CodePudding user response:

I am assuming you have already signed up on GitHub and installed git and git bash on your local machine.

Now, Step 1: create a github repository from github website and copy it's link to clipboard.

Step 2: open a terminal (command prompt) and set the path same as where your code is saved. For example, if your code is in D:/code/mycode then path in your terminal should also be D:/code/mycode.

Step 3: initialize empty git repository in the same location using command git init

Step 4: add remote origin to your online git repository from this location. For that type command git remote add origin <your copied link to the repo here>

Step 5: The above process is only for first time for a particular repository. You have to repeat the following steps every time you want to push code to the repository.

Step 6: stage all the changes in your code since last push by using command git add ..

Step 7: use command git commit -m "<commit message here>" to commit the changes.

Step 8: finally use git push -u origin master

and here you go. You will see your code pushed in the online repository. In the above process, you may be asked to login in github if you are using it first time. So simply login with your username and password.

CodePudding user response:

This is kind of a general question, I am sorry for being straight forward but, literally, look up source control on google and see your options GitHub is just one of them, if you have a hard time using GitHub, there are many other options out there, like GitLab, git(different from GitHub) and many more. but the general idea, what to look into is Source control.

also, turn auto-save ON.

  •  Tags:  
  • git
  • Related