Git reset origin/master
up vote
0
down vote
favorite
I have two servers. One for development and one for production. Both are in Gitlab. I work alone and now I have messed up my git origin.
In development server:
- I created a new branch and made some changes with commit.No push
- Then in the same branch I made some other changes with another commit.No push
- Last in the same branch I made some other changes with another commit.
But I made a serious mistake. After third commit I pushed and merged with origin. This was wrong because I wanted only the last commit to merge with origin. All other was testing. I though that I can work these in parallel but probably I did it with wrong way.
Now when I try in production server to pull the changes I get all three commits.
In production server I have a branch called "right-branch" which everything is ok.
What I want is to clone this branch to origin master and pull origin to development server so I can start again.
How can I do that?
git ubuntu
add a comment |
up vote
0
down vote
favorite
I have two servers. One for development and one for production. Both are in Gitlab. I work alone and now I have messed up my git origin.
In development server:
- I created a new branch and made some changes with commit.No push
- Then in the same branch I made some other changes with another commit.No push
- Last in the same branch I made some other changes with another commit.
But I made a serious mistake. After third commit I pushed and merged with origin. This was wrong because I wanted only the last commit to merge with origin. All other was testing. I though that I can work these in parallel but probably I did it with wrong way.
Now when I try in production server to pull the changes I get all three commits.
In production server I have a branch called "right-branch" which everything is ok.
What I want is to clone this branch to origin master and pull origin to development server so I can start again.
How can I do that?
git ubuntu
Possible duplicate of I need to pop up and trash away a "middle" commit in my master branch. How can I do it?
– Karol Dowbecki
Nov 21 at 22:31
If you have the permission on the server you can force-push an older commit. However you must coordinate this with all other developers pulling from that branch and be careful not to delete anything.
– eckes
Nov 21 at 22:59
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have two servers. One for development and one for production. Both are in Gitlab. I work alone and now I have messed up my git origin.
In development server:
- I created a new branch and made some changes with commit.No push
- Then in the same branch I made some other changes with another commit.No push
- Last in the same branch I made some other changes with another commit.
But I made a serious mistake. After third commit I pushed and merged with origin. This was wrong because I wanted only the last commit to merge with origin. All other was testing. I though that I can work these in parallel but probably I did it with wrong way.
Now when I try in production server to pull the changes I get all three commits.
In production server I have a branch called "right-branch" which everything is ok.
What I want is to clone this branch to origin master and pull origin to development server so I can start again.
How can I do that?
git ubuntu
I have two servers. One for development and one for production. Both are in Gitlab. I work alone and now I have messed up my git origin.
In development server:
- I created a new branch and made some changes with commit.No push
- Then in the same branch I made some other changes with another commit.No push
- Last in the same branch I made some other changes with another commit.
But I made a serious mistake. After third commit I pushed and merged with origin. This was wrong because I wanted only the last commit to merge with origin. All other was testing. I though that I can work these in parallel but probably I did it with wrong way.
Now when I try in production server to pull the changes I get all three commits.
In production server I have a branch called "right-branch" which everything is ok.
What I want is to clone this branch to origin master and pull origin to development server so I can start again.
How can I do that?
git ubuntu
git ubuntu
edited Nov 22 at 21:34
asked Nov 21 at 22:22
G. G.
729
729
Possible duplicate of I need to pop up and trash away a "middle" commit in my master branch. How can I do it?
– Karol Dowbecki
Nov 21 at 22:31
If you have the permission on the server you can force-push an older commit. However you must coordinate this with all other developers pulling from that branch and be careful not to delete anything.
– eckes
Nov 21 at 22:59
add a comment |
Possible duplicate of I need to pop up and trash away a "middle" commit in my master branch. How can I do it?
– Karol Dowbecki
Nov 21 at 22:31
If you have the permission on the server you can force-push an older commit. However you must coordinate this with all other developers pulling from that branch and be careful not to delete anything.
– eckes
Nov 21 at 22:59
Possible duplicate of I need to pop up and trash away a "middle" commit in my master branch. How can I do it?
– Karol Dowbecki
Nov 21 at 22:31
Possible duplicate of I need to pop up and trash away a "middle" commit in my master branch. How can I do it?
– Karol Dowbecki
Nov 21 at 22:31
If you have the permission on the server you can force-push an older commit. However you must coordinate this with all other developers pulling from that branch and be careful not to delete anything.
– eckes
Nov 21 at 22:59
If you have the permission on the server you can force-push an older commit. However you must coordinate this with all other developers pulling from that branch and be careful not to delete anything.
– eckes
Nov 21 at 22:59
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
G. , In my opinion is you can use 'git log' command and check previous commits on your branch. Then you can copy the commit head id and roll back the previous version(the version before all these commit) using 'git reset --hard commitHeadId'. Then you can ignore the previous changes and add only third commit changes using local history or compare with branch and then commit and push.
I have messed my git and I am stucked now. I don't know what to do
– G. G.
Nov 22 at 21:28
add a comment |
up vote
0
down vote
accepted
I managed to solve this without losing any files.
First on production server, in branch which was fine I run:
git push origin --force
This overwritten my origin with the branch which had the "good" files and I needed.
Then in my development server I run:
git checkout master
to switch to master branch and then I run:
git pull
to pull all the new files from origin.
This gave me in development what I needed. A fresh start without losing the other "test" branches.
Then I went back to production server to fix the local master branch also.
I run
git checkout master
git pull
These gave me also a new "fixed" master branch like it was before.
Now I have both servers which are identical in git master branch and I can continue the work with new branches in development server,merge them to remote origin, so I can pull them in production server master branch.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
G. , In my opinion is you can use 'git log' command and check previous commits on your branch. Then you can copy the commit head id and roll back the previous version(the version before all these commit) using 'git reset --hard commitHeadId'. Then you can ignore the previous changes and add only third commit changes using local history or compare with branch and then commit and push.
I have messed my git and I am stucked now. I don't know what to do
– G. G.
Nov 22 at 21:28
add a comment |
up vote
0
down vote
G. , In my opinion is you can use 'git log' command and check previous commits on your branch. Then you can copy the commit head id and roll back the previous version(the version before all these commit) using 'git reset --hard commitHeadId'. Then you can ignore the previous changes and add only third commit changes using local history or compare with branch and then commit and push.
I have messed my git and I am stucked now. I don't know what to do
– G. G.
Nov 22 at 21:28
add a comment |
up vote
0
down vote
up vote
0
down vote
G. , In my opinion is you can use 'git log' command and check previous commits on your branch. Then you can copy the commit head id and roll back the previous version(the version before all these commit) using 'git reset --hard commitHeadId'. Then you can ignore the previous changes and add only third commit changes using local history or compare with branch and then commit and push.
G. , In my opinion is you can use 'git log' command and check previous commits on your branch. Then you can copy the commit head id and roll back the previous version(the version before all these commit) using 'git reset --hard commitHeadId'. Then you can ignore the previous changes and add only third commit changes using local history or compare with branch and then commit and push.
answered Nov 22 at 18:38
JohnC
42
42
I have messed my git and I am stucked now. I don't know what to do
– G. G.
Nov 22 at 21:28
add a comment |
I have messed my git and I am stucked now. I don't know what to do
– G. G.
Nov 22 at 21:28
I have messed my git and I am stucked now. I don't know what to do
– G. G.
Nov 22 at 21:28
I have messed my git and I am stucked now. I don't know what to do
– G. G.
Nov 22 at 21:28
add a comment |
up vote
0
down vote
accepted
I managed to solve this without losing any files.
First on production server, in branch which was fine I run:
git push origin --force
This overwritten my origin with the branch which had the "good" files and I needed.
Then in my development server I run:
git checkout master
to switch to master branch and then I run:
git pull
to pull all the new files from origin.
This gave me in development what I needed. A fresh start without losing the other "test" branches.
Then I went back to production server to fix the local master branch also.
I run
git checkout master
git pull
These gave me also a new "fixed" master branch like it was before.
Now I have both servers which are identical in git master branch and I can continue the work with new branches in development server,merge them to remote origin, so I can pull them in production server master branch.
add a comment |
up vote
0
down vote
accepted
I managed to solve this without losing any files.
First on production server, in branch which was fine I run:
git push origin --force
This overwritten my origin with the branch which had the "good" files and I needed.
Then in my development server I run:
git checkout master
to switch to master branch and then I run:
git pull
to pull all the new files from origin.
This gave me in development what I needed. A fresh start without losing the other "test" branches.
Then I went back to production server to fix the local master branch also.
I run
git checkout master
git pull
These gave me also a new "fixed" master branch like it was before.
Now I have both servers which are identical in git master branch and I can continue the work with new branches in development server,merge them to remote origin, so I can pull them in production server master branch.
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
I managed to solve this without losing any files.
First on production server, in branch which was fine I run:
git push origin --force
This overwritten my origin with the branch which had the "good" files and I needed.
Then in my development server I run:
git checkout master
to switch to master branch and then I run:
git pull
to pull all the new files from origin.
This gave me in development what I needed. A fresh start without losing the other "test" branches.
Then I went back to production server to fix the local master branch also.
I run
git checkout master
git pull
These gave me also a new "fixed" master branch like it was before.
Now I have both servers which are identical in git master branch and I can continue the work with new branches in development server,merge them to remote origin, so I can pull them in production server master branch.
I managed to solve this without losing any files.
First on production server, in branch which was fine I run:
git push origin --force
This overwritten my origin with the branch which had the "good" files and I needed.
Then in my development server I run:
git checkout master
to switch to master branch and then I run:
git pull
to pull all the new files from origin.
This gave me in development what I needed. A fresh start without losing the other "test" branches.
Then I went back to production server to fix the local master branch also.
I run
git checkout master
git pull
These gave me also a new "fixed" master branch like it was before.
Now I have both servers which are identical in git master branch and I can continue the work with new branches in development server,merge them to remote origin, so I can pull them in production server master branch.
answered Nov 23 at 13:39
G. G.
729
729
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421269%2fgit-reset-origin-master%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Possible duplicate of I need to pop up and trash away a "middle" commit in my master branch. How can I do it?
– Karol Dowbecki
Nov 21 at 22:31
If you have the permission on the server you can force-push an older commit. However you must coordinate this with all other developers pulling from that branch and be careful not to delete anything.
– eckes
Nov 21 at 22:59