git-pull

Git pull after forced update

半腔热情 提交于 2019-11-26 03:46:36
问题 I just squashed some commits with git rebase and did a git push --force (which is evil, I know). Now the other software engineers have a different history and when they do a git pull , Git will merge. Is there a way to fix this, except doing a rm my-repo; git clone git@example.org:my-repo.git ? I need something like the opposite of git push --force , but git pull --force did not give the intended results. 回答1: To receive the new commits git fetch Reset You can reset the commit for a local

How do I ignore an error on 'git pull' about my local changes would be overwritten by merge?

无人久伴 提交于 2019-11-26 02:59:26
问题 How do I ignore the following error message on Git pull? Your local changes to the following files would be overwritten by merge What if I want to overwrite them? I\'ve tried things like git pull -f , but nothing works. To be clear, I only want to overwrite specific changes, not everything. 回答1: If you want remove all local changes from your working copy, simply stash them: git stash save --keep-index If you don't need them anymore, you now can drop that stash: git stash drop If you want to

Difference between git pull and git pull --rebase

强颜欢笑 提交于 2019-11-26 02:27:01
问题 I started using git sometime back and do not fully understand the intricacies. My basic question here is to find out the difference between a git pull and git pull --rebase , since adding the --rebase option does not seem to do something very different : just does a pull. Please help me with understanding the difference. 回答1: git pull = git fetch + git merge against tracking upstream branch git pull --rebase = git fetch + git rebase against tracking upstream branch If you want to know how git

git stash and apply

守給你的承諾、 提交于 2019-11-26 01:58:28
问题 I\'m new to git and not quite clear on how stashing works. Let\'s say I\'m working on branch master and try to git pull and receive the error that my local changes would be overwritten and need to be stashed or committed. If I haven\'t staged any of my changes and run git stash , then do a git pull and and update successfully, what happens when I git stash apply ? In general, If someone else modifies files and I run git pull , what happens when I run git stash apply ? does it overwrite the

Git push requires username and password

牧云@^-^@ 提交于 2019-11-26 01:21:23
问题 I cloned a Git repository from my GitHub account to my PC. I want to work with both my PC and laptop, but with one GitHub account. When I try to push to or pull from GitHub using my PC, it requires username and password, but not when using the laptop! I don\'t want to type my username and password every time I interact with origin. What am I missing here? 回答1: A common mistake is cloning using the default (HTTPS) instead of SSH. You can correct this by going to your repository, clicking

Merge, update, and pull Git branches without using checkouts

你离开我真会死。 提交于 2019-11-25 23:26:07
问题 I work on a project that has 2 branches, A and B. I typically work on branch A, and merge stuff from branch B. For the merging, I would typically do: git merge origin/branchB However, I would also like to keep a local copy of branch B, as I may occasionally check out the branch without first merging with my branch A. For this, I would do: git checkout branchB git pull git checkout branchA Is there a way to do the above in one command, and without having to switch branch back and forth? Should

Can “git pull” automatically stash and pop pending changes?

亡梦爱人 提交于 2019-11-25 22:05:15
问题 I know how to solve this: user@host$ git pull Updating 9386059..6e3ffde error: Your local changes to the following files would be overwritten by merge: foo.bar Please, commit your changes or stash them before you can merge. Aborting But isn\'t there a way to let git pull do the stash and pop dance for me? If this command has a different name, it\'s ok. Creating a shell alias for git stash; git pull; git stash pop is a solution, but I search for a better solution. 回答1: For Git 2.6+ (released

How do I force “git pull” to overwrite local files?

浪尽此生 提交于 2019-11-25 21:49:47
问题 How do I force an overwrite of local files on a git pull ? The scenario is following: A team member is modifying the templates for a website we are working on They are adding some images to the images directory (but forgets to add them under source control) They are sending the images by mail, later, to me I\'m adding the images under the source control and pushing them to GitHub together with other changes They cannot pull updates from GitHub because Git doesn\'t want to overwrite their

What is the difference between 'git pull' and 'git fetch'?

我们两清 提交于 2019-11-25 21:41:00
问题 Moderator Note: Given that this question has already had sixty-seven answers posted to it (some of them deleted), consider whether or not you are contributing anything new before posting another one. What are the differences between git pull and git fetch ? 回答1: In the simplest terms, git pull does a git fetch followed by a git merge . You can do a git fetch at any time to update your remote-tracking branches under refs/remotes/<remote>/ . This operation never changes any of your own local