Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git pull analogous to / opposite of git push -f? [duplicate]

Sometimes, esp. when I'm the only one working on a remote repository, I like rewriting the history with git rebase -i and git push origin master -f.

How do I do a forced git pull origin master without a merge? I tried it with the -f option, but that didn't work. I just want to rewrite the history of my local git repo to match that of the remote (origin).

like image 989
ma11hew28 Avatar asked Aug 01 '11 12:08

ma11hew28


People also ask

What is the opposite of git push?

“git pull” is not the opposite of “git push”; the closest there is to an opposite of “git push” is “git fetch”.

What is the opposite command of git clone?

Then, if you want to upload something to your remote repository commit changes and use git push .

Can I push to a cloned repo?

After creating the repository, copy the repo URL. Now, add the URL to your repo. Now you can push/publish it to your own repository!


2 Answers

git fetch git reset --hard origin/master 
like image 177
ma11hew28 Avatar answered Oct 15 '22 11:10

ma11hew28


With respect it is a few years old, the answer by MattDiPasquale will destroy any local changes or commits.

If you have local changes or commits, but need to rewrite history, run:

git fetch origin git rebase origin/master 
like image 29
Jason McCreary Avatar answered Oct 15 '22 10:10

Jason McCreary