SmartGit pull not acting like expected
Pergunta
I forked a repository on GitHub.
I then cloned my fork into a folder on my local development enviroment through SmartGit. Additionally I added the original repository as a remote.
Now, the original repository has added and changed some files. I'd like to retrieve these so that I'm up to date, before continuing with developing.
I the push the Pull button in SmartGit and select the original repo i the dialog. SmartGit returns this to me:
remote: Counting objects: 24, done.
remote: Total 13 (delta 7), reused 12 (delta 6)
From github.com:Original/repo
* [new branch] master -> lm/master
But, the added files and changes are not added to my local repository.
Doing this manually with Git Bash - git pull original master
everything works like expected.
Why is it SmartGit doesn't pull like I expect?
Solução
On Pull, SmartGit will perform a "git fetch" and after that merge resp. rebase the tracked branch. In your case, master
tracks origin/master
, not lm/master
. You have following choices now, always assuming you are on master
:
(1) Configure master
to track lm/master
instead of origin/master
: invoke Branch|Branch Manager, select master
, invoke Reset Tracked Branch from the context menu, then add lm/master
to the selection and invoke Set Tracked Branch. Now, it's lm/master
which will be merged (or rebased) on every Pull.
(2) Manually merge lm/master
: invoke Branch|Merge and select lm/master
.
(3) Manually rebase onto lm/master
: invoke Branch|Rebase
, select HEAD to selected commits and on the graph-page, select lm/master.
Outras dicas
What I ended up doing in SmartGit was:
Remote > Add
(as you did). I called mine upstream.- In the branches panel
Right click upstream > fetch more..
and select the branches. (Typically master) - In the branches panel
Double click upstream > master
. This will ask you to create a 2nd branch (usually master-2). I also called this upstream. So I have a remote repo called upstream and local branch called upstream that tracks upstream/master. - In the branches panel
Double click Local Branches > Master
to get you back to your master branch.
At this point I would presume you only just forked the project a few moments ago, so this next step would not be very useful, but if there are a few extra commits at a later stage you will need to do this.
Remote > Pull
and select upstream. If you press the little down arrow, you will see you can ONLY do "Neither merge nor rebase". This is good.Click fetch
This will allow you to see all the log and what has changed.- In the branch panel
Right click Local Branches > upstream > Merge
. Fast-Forward
if you believe you can. (My preferred way).- or
Create Merge-Commit.
From this point on, You would only have to do is the last 5 steps. The first steps were just setup.
You would see the new files if the upstream branch of your current local branch was "lm/master
".
But if you are on master
, its upstream branch is certainly by default "origin/master
" (ie the master
of your fork)
If you want to merge the files from the original repo, complete your command with a
git merge lm/master
Or, in SmartGit, merge from lm/master
to your current branch.
if SmartGit is performing Fetch on your every Pull,
Then locate the branches option in menu bar or branches window from the application..
Then
OR
Voila... Enjoy