Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
165 views
in Technique[技术] by (71.8m points)

git - How to add a new file to an existing repository using VS Code

I had a single python script, but I separated the code into different files eg. Grace.py, Grace1.py etc.

I want to add these new files to my git repository that I already created but I don't know how. How do I get all three code scripts to be in one repository?

question from:https://stackoverflow.com/questions/66050092/how-to-add-a-new-file-to-an-existing-repository-using-vs-code

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I would really recommend using the CLI of git instead of vscode, at least at the begining, but if you insist on using vscode for that, this easily done with this explanation:

  1. press on the version control button(#1 in the picture)
  2. hover the files you want to add and press the '+' button (#2)
  3. When you are done adding, commit your work pressing on the 'v'(#3) and then add a message on the text box(#4) and press enter.

enter image description here

This will create a new commit to save changes locally.

To save the code in a remote repository you need to push your commits. You can do it using the the push command. Again, I will recommend using CLI but if you insist you can use vscode for that like this(press the 3 dots (...) button to enter to the below menu):

enter image description here

P.s. Make sure your repository saves the proper remote destination.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...