Search code examples
gitversion-controlsmartgit

Push/Pull errors with setting up Git locally using SmartGit


I would like to start using DVCS with Git for a project on my local PC. It's a private project and is to allow me to keep track of changes and versions, and in the future allow outside developers to contribute to the project. For now though I'd like to just stick with a local setup. I'm using SmartGit as my git client.


This has been my setup process:

  1. Open SmartGit -> Repository -> Add or Create...
  2. Add path to my current project folder
  3. Select project in repositories pane
  4. Stage (all files) -> Commit
  5. Branch is set as 'master'

I'd like this to be my central repository, for files to be pushed to, which will be backed up.

Now to create my working repository:

  1. Repository -> Clone -> Local Git repository -> Path to the repo I just created
  2. Include Submodules, fetch all Heads and Tags

My new repo is now created.


Now testing a change to push to the central repo:

  1. Navigate to a text file in the working repo (in the repo pane) and open and edit it.
  2. Save changes -> Stage -> Commit and Push:

Error:

Error not all refs have been pushed -> 'master' rejected (non-fast-forward)

Following my research I try this:

  1. In the working repo Pull -> Rebase (The recommended way following the tool-tip)
  2. Fetch from Path/To/Central/Repo
  3. Pull

Now to retry:

  1. Push -> Current branch 'master'

Again:

Error not all refs have been pushed -> 'master' rejected (non-fast-forward)

I now try to fix the error:

  1. (working repo) Merge -> master 'Changes' -> Create Merge-Commit -> Fast-Forward

Message:

"Already up-to-date"
  1. Merge -> master 'Changes' -> Create Merge-Commit

Again:

"Already up-to-date"

I then try and pull from the central repo:

  1. (central repo) Pull -> Set remote -> Path/To/Working/Repo
  2. Can't Pull can only Fetch

Still same error when I now try and push the changes.

I'm struggling to find out how to push to my central repo.

Thanks in advance!


Solution

  • My suspect is that your local master might not be tracking origin/master. Also, your central repository should be bare, hence I'd recommend to start over again:

    1. Make sure your central repository is bare. Therefore, create a new repository using `git init --bare' from command line.

    With SmartGit:

    1. Create a clone from your central repository, using Clone. This will issue a warning like warning: You appear to have cloned an empty repository.

    2. Move your existing sources/whatever into the clone and Commit. This will automatically put you onto master.

    3. Finally, invoke Push and confirm to Configure tracking between master and origin/master.