마스터와 개발 분기 병합
두 개의 분기 즉 master
, development
GitHub 저장소에 있습니다. 표시된대로 개발 브랜치에서 모든 개발을 수행하고 있습니다.
git branch development
git add *
git commit -m "My initial commit message"
git push -u origin development
이제 development
분기의 모든 변경 사항을 master
. 내 현재 접근 방식은 다음과 같습니다.
git checkout master
git merge development
git push -u origin master
내가 따르는 절차가 올바른지 알려주십시오.
나는 일반적으로 첫 번째 로 병합 master
하여 development
충돌이 발생하면 development
분기 자체 에서 해결할 수 있고 내 master
상태는 깨끗합니다.
(on branch development)$ git merge master
(resolve any merge conflicts if there are any)
git checkout master
git merge development (there won't be any conflicts now)
두 가지 접근 방식에는 큰 차이가 없지만 때때로 브랜치를 병합 한 master
후 아직 병합하고 싶지 않거나 병합 하기 전에 수행해야 할 작업이 더 많다는 것을 가끔 발견 했습니다. , 그래서 나는 master
마지막 물건까지 그대로 두는 경향이 있습니다.
편집 : 댓글에서
--no-ff
병합을 수행 한 사람과시기를 추적하려면 병합 하는 동안 플래그를 사용 하여이를 수행 할 수 있습니다. 이 병합 경우에만 일반적으로 유용 development
에 master
병합해야 할 수도 있기 때문에, (마지막 단계) master
로 development
워크 플로우에 (첫 번째 단계)를 여러 번, 그리고 매우 유용하지 않을 수도 있습니다 이들에 대한 노드를 커밋 작성.
git merge --no-ff development
개인적으로 내 접근 방식은 몇 가지 더 많은 브랜치와 마스터로 돌아갈 때 커밋을 스쿼시하는 것과 유사합니다.
내 동료 중 한 명이 브랜치를 너무 많이 바꾸는 것을 좋아하지 않고 개발 브랜치에서 모두 실행되는 다음과 유사한 것을 가지고 개발 브랜치에 머물러 있습니다.
git fetch origin master
git merge master
git push origin development:master
첫 번째 줄은 마지막으로 자신의 로컬 저장소를 업데이트 한 이후 마스터로 만든 업스트림 커밋이 있는지 확인합니다.
두 번째는 마스터에서 개발로 이러한 변경 사항 (있는 경우)을 가져옵니다.
세 번째는 개발 브랜치 (현재 마스터와 완전히 병합 됨)를 오리진 / 마스터로 푸시합니다.
그의 기본 워크 플로가 약간 잘못되었을 수 있지만 이것이 주요 요점입니다.
지점에 대한 지식없이 이곳에 온 분들을 위해 아래에서 설명합니다.
기본 마스터 분기 개발 논리는 다음과 같습니다. 다른 분기에서만 작업하고 마스터 만 사용하여 다른 분기를 병합합니다.
다음과 같은 방법으로 새 분기를 만들기 시작합니다.
1) 웹 루트에서 필요한 저장소 복제 :
$ cd /var/www
$ git clone git@bitbucket.org:user_name/repository_name.git
2) 새 분기를 만듭니다. 마스터 브랜치 저장소의 최신 파일이 포함됩니다.
$ git branch new_branch
3) git 브랜치를 new_branch로 변경
$ git checkout new_branch
4) 평소와 같이 코딩, 커밋을합니다.
$ git add .
$ git commit -m “Initial commit”
$ git push (pushes commits only to “new_branch”)
5)이 브랜치에서 작업이 완료되면 "마스터"브랜치와 병합합니다.
$ git merge master
$ git checkout master (goes to master branch)
$ git merge development (merges files in localhost. Master shouldn’t have any commits ahead, otherwise there will be a need for pull and merging code by hands!)
$ git push (pushes all “new_branch” commits to both branches - “master” and “new_branch”)
업데이트 : GitKraken을 사용하여 시각적 변경 트리를보고 모든 로직과 커밋을 더 잘 볼 수 있도록하는 것이 좋습니다.
Git Flow 워크 플로를 사용할 수 있다면 좋을 것 입니다. 개발 브랜치를 마스터로 쉽게 병합 할 수 있습니다.
원하는 것은 여기에 언급 된 git-flow 지침을 따르는 것입니다.
단계 :
- git-flow 프로젝트 설정
- 분기를 만들고 모든 것을 병합하여 개발
- 명령을 실행
git flow release start <version_number>
- 그런 다음 릴리스에 대한 의미있는 메시지 를 제공하십시오.
- 명령을 실행
git flow release finish <version_number>
- it will merge everything into master and change the branch to master.
- run the command
git push
to publish the changes to the remote master.
For more information, visit the page - http://danielkummer.github.io/git-flow-cheatsheet/
1. //pull the latest changes of current development branch if any
git pull (current development branch)
2. //switch to master branch
git checkout master
3. //pull all the changes if any
git pull
4. //Now merge development into master
git merge development
5. //push the master branch
git push origin master
Yes, this is correct, but it looks like a very basic workflow, where you're just buffering changes before they're ready for integration. You should look into more advanced workflows that git supports. You might like the topic branch approach, which lets you work on multiple features in parallel, or the graduation approach which extends your current workflow a bit.
If you are on Mac or Ubuntu, go to the working folder of the branch. In the terminal
suppose harisdev is the branchname.
git checkout master
if there are untracked or uncommitted files you will get an error and you have to commit or delete all the untracked or uncommitted files.
git merge harisdev
git push origin master
One last command to delete the branch.
$ git branch -d harisdev
Step 1
Create and switch to a new "dev" branch, where your local git files are in-synced with the remote but "dev" branch does not exist yet.
git branch dev # create
git checkout dev # switch
# No need to git add or git commit, the current
# branch's files will be cloned to the new branch by-default.
git push --set-upstream origin dev # push the "dev" branch to the remote.
Step 2
Make your changes to the "dev" branch (your current if you follow step 1), commit and push them to the remote "dev" branch.
git add .
git commit -S -m "my first commit to the dev branch" # remove the -S if you're not "secure", secure = when you already setup crypto private and public keys (i.e "verified" green sign in github)
git push -u origin dev # push the changes to the remote, -u origin dev is optional but good to use.
Step 3
Merge your "dev" branch into the "master".
git checkout dev # switch to "dev" branch if you're not already.
git merge master # optionally, this command is being used to resolve any conflicts if you pushed any changes to your "master" but "dev" doesn't have that commit.
git checkout master # switch to "master", which is the branch you want to be merged.
git merge --no-ff dev # merge the "dev" branch into the "master" one.
This is how I usually do it. First, sure that you are ready to merge your changes into master.
- Check if development is up to date with the latest changes from your remote server with a
git fetch
- Once the fetch is completed
git checkout master
. - Ensure the master branch has the latest updates by executing
git pull
- Once the preparations have been completed, you can start the merge with
git merge development
- Push the changes with
git push -u origin master
and you are done.
You can find more into about git merging in the article.
1) On branch Development, check git status using following command:
git status
There should be no uncommitted code. If it is, push your code on Development branch:
git add *
git commit -m "My initial commit message"
git push origin Development
2) On Development branch, run following two commands:
git branch -f master HEAD
git push -f origin master
It will push your Development branch code to master branch.
Based on @Sailesh and @DavidCulp:
(on branch development)
$ git fetch origin master
$ git merge FETCH_HEAD
(resolve any merge conflicts if there are any)
$ git checkout master
$ git merge --no-ff development (there won't be any conflicts now)
The first command will make sure you have all upstream commits made to remote master, with Sailesh response that would not happen.
The second will perform a merge and create conflicts that you can then resolve.
After doing so, you can finally checkout master to switch to master.
Then you merge the development branch onto the local master. The no-ff flag will create a commit node in master for the whole merge to be trackable.
After that you can commit and push your merge.
This procedure will make sure there's a merge commit from development to master that people can see, then if they go look at the development branch they can see the individual commits you've made to that branch during its development.
Optionally, you can amend your merge commit before you push it, if you want to add a summary of what was done in the development branch.
EDIT: my original answer suggested a git merge master
which didn't do anything, it's better to do git merge FETCH_HEAD
after fetching the origin/master
Once you 'checkout' the development branch you ...
git add .
git commit -m "first commit"
git push origin dev
git merge master
git checkout master
git merge dev
git push origin master
I think the easiest solution would be
git checkout master
git remote update
git merge origin/Develop -X theirs
git commit -m commit -m "New release"
git push --recurse-submodules=check --progress "origin" refs/heads/Master
This also preserves history of all the branches in use
If you are using gerrit, the following commands work perfectly.
git checkout master
git merge --no-ff development
You can save with the default commit message. Make sure, the change id has been generated. You can use the following command to make sure.
git commit --amend
Then push with the following command.
git push origin HEAD:refs/for/refs/heads/master
You might encounter an error message like the below.
! [remote rejected] HEAD -> refs/for/refs/heads/master (you are not allowed to upload merges)
To resolve this, the gerrit project admin has to create another reference in gerrit named 'refs/for/refs/heads/master' or 'refs/for/refs/heads/*' (which will cover all branches in future). Then grant 'Push Merge Commit' permission to this reference and 'Submit' permission if required to Submit the GCR.
Now, try the above push command again, and it should work.
Credits:
https://github.com/ReviewAssistant/reviewassistant/wiki/Merging-branches-in-Gerrit
https://stackoverflow.com/a/21199818/3877642
1. //push the latest changes of current development branch if any
git push (current development branch)
2. //switch to master branch
git checkout master
3. //pull all the changes if any from (current development branch)
git pull origin (current development branch)
4. //Now merge development into master
git merge development
5. //push the master branch
git push origin master
Error
To https://github.com/rajputankit22/todos-posts.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/rajputankit22/todos-posts.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Then Use
5. //push the master branch forcefully
git push -f origin master
참고URL : https://stackoverflow.com/questions/14168677/merge-development-branch-with-master
'programing' 카테고리의 다른 글
Mac OS X에서 Java는 어디에 설치됩니까? (0) | 2020.09.30 |
---|---|
변수에 값을 할당하여 한 줄씩 파일 읽기 (0) | 2020.09.30 |
.whl 파일이있는 Python 패키지를 어떻게 설치합니까? (0) | 2020.09.29 |
T-SQL에서 같지 않은 경우! = 또는 <>를 사용해야합니까? (0) | 2020.09.29 |
Assert를 사용하여 예외가 발생했는지 확인하려면 어떻게합니까? (0) | 2020.09.29 |