I have created a branch and committed to it, got it reviewed and merged with main branch. Now when I try to push another change into another commit with the same branch now I see 2 commits on the branch and if I now merge, the first commit as well as the second will get merged? why is this happening?
Related
Each commit contains 2 files uploaded to GitHub, we have a few of such commits.
we have only one branch (Main), We need to bound these commits with a branch so that we can view all files that were pushed.
The problem comes when we attach a commit with a branch, my new commit deletes every change made by my previous commit
commit 1 : assets/bg1.png
uploads/profile1.png
commit 2 : assets/bg2.png
uploads/profile2.png
For now, if I attach commit-2 with the main branch, It deletes changes made by commit 1
I need both commit changes available in the Git branch
Steps that I followed
https://github.com/Decimal458/test.git
When I create a PR(#3,#5,#7) to merge "dev/" into "stage", the PR include old commit.
But create PR(#4,#6,#8) to merge "dev/" into "main", it would not happend.
In the company I work for, those PRs that are merged into the "stage" may contain more commits and even see other people's files in "Files Changed".
I would like to know how to only display my own commits or files when creating a PR that is merged into stage, just like a PR that is merged into main.
Note: I don't have permission to execute merge in the company.
I would like to know how to only display my own commits or files when creating a PR that is merged into stage, just like a PR that is merged into main.
This is all about rebasing --onto: you rebase only your commits on top of the PR target branch, and then force push your feature branch.
That will update the PR, and show only your own commits.
If you were to make a PR from CVG-xxx to develop, you would see commits from CVG-yyy, because your feature branch was initially create from it.
Assuming CVG-yyy is the commit just before your own CVG-xxx branch:
git fetch
git rebase --onto origin/develop CVG-yyy CVG-xxx
git push --force
The result is: only your own commits are on top of origin/develop now.
Your PR (to origin/develop) will only include your commits.
Someone I work with pulled from the main branch changed a lot of code and merged it with a months old branch. Now a very important file is corrupted and has merging errors. How would you unmerge the commit and push the changes to the main branch instead? I'm not trying to save the old branch but the changes made before the merge.
I have created a branch from another branch. Then I come back to previous branch and work on it. Now I have switched to second branch. But this second branch don't have the new changes of first branch. I just want to update the second branch from first branch without deleting any of them.
But this second branch don't have the new changes of first branch
Switching to the second branch alone is not enough for said branch to reflect changes committed in the first branch.
You would need to git merge branch1 or, if you are the only one working on branch2: git rebase branch1 (if you want to keep a linear history).
Then, and only then, would you see branch1 changes in branch2.
⇒ The OP Waqar Ahmed proposes in the comments:
I have solved this issue but checking out branch2 and pull the branch1
In the PR , after I merged a branch and deleted it, I restored the branch again on the PR.
Locally, then I made changes to the branch and pushed it to the remote branch. The commit is available on the remote branch but it does not come up in the existing merged PR.
After I compare and Pull Request, it is creating a new PR.
Is it possible to add the commit to the old PR itself?
No, you can't re-open the pull request if it was merged.