[英]How to add local repo to the branch
You have to follow few steps.你必须遵循几个步骤。 if you don't have the local repo configured.
如果您没有配置本地存储库。 Do this
做这个
1. Initialize the git for the repostory 1.为repostory初始化git
git init
2. Add your repo origin to git 2. 将你的 repo origin 添加到 git
git remote add origin <YOUR REPO PATH/URL>
Example is below示例如下
git remote add origin https://github.com/github/docs.git
By default it will be in the master/main branch.默认情况下,它将位于 master/main 分支中。
If you have any local changes.如果您有任何本地更改。
3. First stage them and run these commands 3. 首先暂存它们并运行这些命令
git add .
git commit -m "Your message"
git pull
git pull is if you have any changes in the repo but you don't have them, to merge them locally. git pull是如果您在 repo 中有任何更改但您没有更改,请在本地合并它们。
4. Now push the code to the repo. 4. 现在将代码推送到 repo。 git push or
git推或
git push origin YOUR-BRANCH-NAME
Example例子
git push origin master or git push origin main
Now when you're pushing the code for the very first time.现在,当您第一次推送代码时。 Then, follow step 1 and step 2 and write these commands
然后,按照步骤 1和步骤 2编写这些命令
git add .
git commit -m "Your Message"
git push origin Your-Branch-Name
Example例子
git push origin master
You can also find the help here Git Help commands您还可以在此处找到帮助Git 帮助命令
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.