Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Git Bash to upload local projects to GitHub

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

Today, I would like to share with you how to use Git Bash to upload relevant knowledge points of local projects to GitHub. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.

1. Initialize the local warehouse

Open Bash under the project folder and enter the command:

Git init / / initialize the local warehouse

2. Add new test files

Enter the command:

Touch test file. Txt / / New File

3. Add files to the local warehouse

Enter the command:

Git add. / / add all files to the local warehouse

4. Submit all documents

Enter the command:

Git commit-m "git Test" / / submit to local warehouse

5. Switch branches

Enter the command:

Git checkout-b main / /-b indicates that the branch does not exist. A new myProject_v1.0 branch will be created and switched to this branch.

6. Connect to the remote warehouse

Enter the command:

Git remote add origin https://github.com/ITMingliang/MyStudy.git / / remote warehouse address

7. Push to the remote warehouse

Enter the command:

Git push origin main / / push to the remote main branch

8. Error analysis

Do not panic when you find the above push error report, take a look at the prompt to report the reason for the error. The prompt fetch frist is due to the inconsistency between the local warehouse and the remote warehouse, so the latest content needs to be pulled down to the local warehouse for synchronization.

To execute fetch means to pull the latest content of the remote host locally, that is, git pull = git fetch + git merge

Processing method 1: execute git fetch

Method 2: execute git push-forigin main (not recommended, it ignores version inconsistencies)

9. Push operation again and still report an error

10. analysis of the causes of error reporting.

It is usually caused by conflicts, and the solution executes the following command:

Git pull origin main-- allow-unrelated-histories / / pull irrelevant history git push origin main / / push to remote main branch from remote warehouse

After executing the first command, you will find that several new files have been added to the remote warehouse in the local warehouse file directory.

11. Check the remote warehouse for new files, and verify whether it is successful.

These are all the contents of the article "how to use Git Bash to upload local projects to GitHub". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report