git - 如何使用 GIT 将我的代码从本地机器推送到除 master 之外的不同分支中的 Azure devops?
问题描述
如何使用 GIT 将项目文件夹从我的本地计算机添加到 Azure 上的 git 存储库?
在项目根目录的本地目录中
git init
git remote add origin <URL for Azure Git repo>
git add .
git commit -m 'initial commit'
git push -u origin master
在对堆栈溢出进行基本研究后,我知道这些命令,但我的问题是,如果我们有一个名为“ dev ”的分支,并且我在该分支中创建了一个名为“ sandbox ”的文件夹,那么如果我想在其中添加我的项目我可以通过转到该文件夹复制 https 链接以及应输入的内容来完成特定文件夹
git push -u origin master
而不是大师?我必须写“ dev ”,因为这是我将要推送我的代码的分支吗?
解决方案
要推送到原始开发,您可以这样做
git push -u origin dev
一个快速的 git 教程
我将解释如何创建 git repo、创建新分支、设置上游并将分支推送到远程。
初始化一个 git repo 并在 master 中进行一些虚拟提交
# init a git repo
git init
# Add a remote for the git repo
git remote add origin <URL for Azure Git repo>
# create a dummy file
touch file1
# stage all changes made to git repo so they can be commited
git add .
# make a commit for the staged changes
git commit -m 'initial commit'
# push commit to remote
git push
# The same as previous step, buy done explicitly by specifying the remote address and branch name
git push -u origin master
在新分支中添加演示提交
# create a new file
touch file2
# stage changes
git add .
# decided to push these changes to dev instead of the master branch
# create a new branch and checkout to dev
git checkout -b "dev"
# make commit to the dev branch
git commit -m 'dev commit'
# push the changes
git push
# or
# Only push the changes of dev to remote address origin
git push -u origin dev
最后你的 git log 看起来像这样(带有漂亮的打印和格式)
* 2e48c23 - (HEAD -> dev, origin/dev)
| dev commit - clmno
* fad2e5b - (master, origin/master)
initial commit - clmno
推荐阅读
- sql-server - 分解嵌套的 XML 数据并返回集合
- npm - 如何将带有+登录版本(Semver 2.0.0)的包发布到npm?
- android - 我已经创建了 React 本机应用程序并将其构建为独立的 android apk 文件,但如果不连接到同一网络,我将无法使用它
- visual-studio - 在安装项目中更改了版本,但它仍然不会重新安装?
- mongodb - 努力对 NO-SQL 进行复杂查询
- python - Pandas 数据框中的 Edgelist 使用 networkx 进行可视化
- python-3.x - 给定Python中的变换矩阵,如何将区域转换为原始空间
- python - Python:将 CSV 列解析为 np.array 的行和列索引?
- python - Pandas 中是否有一种方法可以使用已修改的列合并两个数据框而不影响原始数据?
- codeigniter-4 - Codeigniter 4如何显示某个名称出现在X行以上的记录