Multiple files under a single commit through GitHub API - github

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

Related

2 diff commit from same branch but diff merge?

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?

Github Unmerge a Commit and Push it to the right branch

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.

New Pull Request when a previous one is pending Merge

I made some changes to several files of the project on a new branch (let's call it branch_a), I commited them, created the Pull Request, and it was recently reviewed and approved. It's still pending Merge on the master branch.
Now, someone asked for another change. It's a small supplemental change in 1 of the files edited in the first Pull Request.
What's the best way of doing this? Should I ask for the first Pull request to be merged and then create a new branch (branch_b), make my change and create a new Pull Request, ask for review and merge again?
Or is there a "cleaner" way, when the first Pull Request is somehow merged with the second one and we don't have to make 2 different merges?
If another change requested is a part of the same feature as in ‘branch_a’, then you can simply make change in the same branch, your PR request will show up those changes, but PR approval will be required again.
If another change requested is outside the scope of feature ‘branch_a’ and it is just a file is same between two changes, then you can create a new branch out of master say ‘branch_b’, complete your changes and raise PR for the same. After ‘branch_a’ is merged into master, you can rebase your second branch ‘branch_b’ to include updated master codebase into branch_b, (or vice-versa if branch_b is merged first).
This is especially useful if the order of merge is not decided in advance.
Below are the steps, for rebase, here ‘feature_branch’ is the name of your branch for which you want to perform rebase:
git checkout master
git pull origin master
git checkout feature_branch
git rebase master
Here you might get some conflicts(if there are any) multiple times as per number of commits in your feature_branch. You can resolve the conflicts manually and proceed with further process of rebase with below command:
git rebase --continue
At any point if you think that things are not going well and you would like to cancel rebase process, then execute below command:
git rebase --abort
Finally when all conflicts are resolved and you get message as successfully merged, then execute below command to push changes to origin:
git push --force origin feature_branch
for more information on rebase process follow link:
https://www.atlassian.com/git/tutorials/rewriting-history/git-rebase
Branch off the first pull request branch, edit, add, commit, push, and ask for a second PR merging to the first branch. When the first branch is merged the second PR will be reconfigured automatically (by GitHub) to be merged into the main branch.

How to add a commit done on a restored branch to an old PR?

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.

Eclipse github How to change my Project message when i have pushed

I first commit blog, the messages is ok.
When I push next time, the message is no change.
I check my history, these were be pushed
What is master & HEAD?
How to change my Project message when I have pushed?
To modify a commit message right-click the commit and choose Modify > Reword. Technically, changing the commit message means to replace the commit and all its subsequent commits with a new commit due the message and the references to the parent(s) are part of the commit (you can see this by the fact that the Id of the commit has changed).
If you have already pushed the replaced commenit, the rewritten Git history requires a force-push: right-click the HEAD commit and choose Push Commit.... In the Push Branch master dialog check the option Force overwrite branch in remote if it exist and has diverged. But beware, rewriting the remote Git history is problematic when you collaborate with others via your GitHub repository. Therefor GitHub allows to disable force pushing.
What is master & HEAD?
The commit where you are (in your local repository) is marked with HEAD. The latest/head commit of a branch is marked with the branch name: master is the name of the main/default branch (like trunk in SVN/Subversion).