git 获取远程分支

mac2022-06-30  99

git     remote branch

_____________________________________________________________

mkdir branchProjectName

cd branchProjectName

git init

git remote add -t $branchName -f origin $remote_repo

git checkout $branchName

git remote branch 2 _____________________________________________________________

git clone remote_repo

#查看分支,

git branch -A 

#切换到你需要的分支

git checkout brachName

#添加修改的文件到本地缓存,待commit  。  

# 添加所有更改的或者新加如的文件

git add . 

#添加指定文件

git add filePath

#提交更改

git commint -m "你修改了什么内容"

#推送到远程

git push <remote> <branch>

_____________________________________________________________ git fork push and sync #fork 别人的一个项目然后更改, 可以利用上面两个方法获取代码 更改完成后,先提交 #当别人的项目有了更新,如何更新到我们fork的项目中 1查看remote版本 添加别人的项目源 git remote add upstream other_repo 查看 git remote -v  origin  https://github.com/xxxxxxxxxxx.git (fetch) origin  https://github.com/xxxxxxxxxxx.git (push) upstream        https://github.com/xxxxxxxxxxx.git (fetch) upstream        https://github.com/xxxxxxxxxxx.git (push) 获取other_repo 的更新 git fetch upstream 切换到自己需要更新的分支 git checkout branchName 合并 git merge upstream/branchName (合并出现冲突) 放弃本地修改,按照更新的远程分支 git reset --hard 保存本地修改 git stash 推送修改 git push origin myBranchName

转载于:https://www.cnblogs.com/mendeliang/p/5070831.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)