好吧,我来自SVN背景。
我正在开发一个项目,其代码在git上维护。
我所拥有的只是一个克隆URL。所以我做了
git clone repo_url repo_name
。
对此副本进行更改/工作的首选方法是什么。就像我需要做git checkout someBranch等?然后我如何将更改推回到git。
以下步骤是否正确提交并推回到远程存储库?
git add .
git commit -m "message"
git push remotebranch localbranch
如果是,那么localbranchname或remotebranchname被替换为什么?
答案 0 :(得分:0)
您可以通过此命令检查遥控器
git remote
大部分时间git remote
都设置为origin
现在接下来的问题,你如何检查原点是什么
git remote show origin
这将返回如下内容,您可以在其中找到存储库的git服务器,它还将列出远程控制的分支:
* remote origin
URL: me@remote.example.com:~/something.git
Remote branch merged with 'git pull' while on branch master
master
Tracked remote branch
master
现在你的第一个问题是做出改变的首选方式是什么:
您应该通过
创建一个本地分支git checkout -b "your Branch name"
在此分支中进行更改并在需要时提交它们。现在,一旦验证了所有更改,将它们合并到主分支(通常是其主分支)。所以合并你要做的是如下(我假设你的主分支是主): git chekcout大师 git合并“你的分支名称”
就是这样。现在,您可以通过以下方式将主人推送到服务器:
git push
或
git push origin master
答案 1 :(得分:0)
检查git repo:
# Any of the below works
vim REPO/.git/config # You can even change it from here
git remove -v
推动变革:
git add . # this will add all from the `.` directory
git commit -m "My changes" # or `git commit` for interactive editor
git push
切换分支:
git checkout <branch>
享受