Reputation: 757
I have some Git-related doubt.
I have done some changes from master branch and by mistake I have commited to master branch. I did:
git add.
git commit "my changed"
But I could not push to the master branch due to some issues. So I have created another branch and from that branch I did push. But I was getting conflicts.
So my doubts are:
If I created a new branch again from master whether I will have all committed changes from the master?
What step do I need to follow to fix this conflict?
What do I need to do to make my master branch as same as server?
If I clone the project again, will it have my committed changes or same as server?
Can I do like? Clone again the master, checkout to the branch I got conflict, do:
git merge master
From there and fix the conflicts?
Upvotes: 0
Views: 78
Reputation: 11
Just hit git log
to find if you have all commits from master if your HEAD is ahead or at same level as master which means you have all commits from master (or) If you have created a branch from master
git checkout master
git checkout -b new-branch
then YES.
When you have conflicts you have to resolve using
git mergetool
Check git status
whether you have resolved your conflicts
If you want to get local master reset to remote master branch
git checkout -B master origin/master
If you had pushed the commit on other branch instead of master, it will be on the remote other branch not on origin/master.
So when you are pushing new changes to remote custom branch,
git fetch origin master
git checkout custom-branch
git rebase -i origin/master
git commit -m 'Your new feature stuff'
git push origin custom-branch
This will only push to remote custom-branch not to master.
Create a merge request for merging to remote master.
Upvotes: 1
Reputation: 2814
Yes
EIther rebase/merge your branch withh/into master and resolve the conflicts using
git rebase origin/master
git merge origin/master
Reset the branch with master using
git reset --hard origin/master
Yes
To conclude, in order to resolve your problems on the branch currently, you should do the following
git checkout branchA
git merge origin/master // resolve conflicts here
git commit
git push
Upvotes: 0