Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Click the button Add an existing local Git Repository to this view in the Git Repositories view and enter the local path.
  2. Right-click the Working directory entry in the added repository, select Import Projects, Next, select the projects that you want in your workspace, Finish.

Updating the Repository

Your working copy must be clean before you can merge any updates into it. Therefore, always commit your changes locally before you pull. If you don't want to commit them into the master branch, commit them into a new branch. Note that pulling is the same as fetching remote changes and merging them into your local branch. Since a normal merge operation is involved, this can lead to conflicts, which need to be resolved as described below. Note that pulling always merges the remote changes into your current branch. If that's not what you want, checkout the correct branch first or just do a fetch.

Do one of the following three things:

  • Right-click one of the KIELER projects, then from the Team submenu choose Pull.
  • Right-click the KIELER repository in the Git Repositories view and click Pull.
  • Enter git pull on the command line and refresh your workspace.

Resolving Conflicts

Whenever branches are merged or rebased, conflicts can occur. They can be resolved by adjusting the state of your working copy, marking it as clean, and committing the changes. Conflicted files are modified so they contain both your version and the remote version. Edit them until all conflict areas are clean. In Eclipse this can be done by right-clicking the conflicted files - Team - Merge Tool.

Warning
titleWarning

If you try to pull from a remote repository or merge branches although you have local uncommitted changes, and the merge would affect the same files, Git leaves those files as they are, thus discarding the changes that would be made by the pull or merge operation. As a consequence, committing such a conflicted state would ignore the changes of the merged branch even if the commit graph looks like a regular merge has happened. Therefore keep in mind never to pull or merge with uncommitted changes.

Taking your version of conflicted files: git checkout --ours <path>

Taking the remote version of conflicted files: git checkout --theirs <path>

Committing Changes

Git manages changes in two separate steps:

  1. Commit changes to your local repository.
  2. Push the commit to the remote repository.

The first step can be done offline, which is very useful in situations where you don't have an internet connection, but would like to save intermediate development snapshots in the history. You can push multiple commits to the remote repository, which for example means that if you are performing changes that would create broken intermediate states, you can commit any number of snapshots locally and only push the whole bundle of commits after you have reached a state that works again.

If another developer has pushed changes since the last time you have pulled from the server, your attempt to push your commits online may fail. In this case you need to pull the remote changes before you can push. Never use force pushing! (git push -f)

Info
titleBefore you proceed...

Before you commit anything, make sure you have set up your name and email address properly, as described on the Configuring Eclipse page.

Committing

To commit changes with EGit, do one of the following and select the files you would like to commit:

  • Right-click one of the KIELER projects, and from the Team submenu, choose Commit.
  • Right-click the KIELER repository in the Git Repositories view and choose Commit.

To commit your changes on the command line, do the following:

  1. Use git add to select (stage) the files you would like to commit (new files as well as modified files).
  2. Enter git commit to create a commit from the staged files.

Pushing

To push your commits to a remote repository with EGit, do one of the following:

  • Right-click one of the KIELER projects, and from the Team submenu, choose Push to Upstream.
  • Right-click the KIELER repository in the Git Repositories view and choose Push to Upstream.

To push your commits on the command line, enter git push.