Versions Compared

Key

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

...

  • git status - At any time, you may use this command to determine the status of your local git repository and how many commits ahead or behind it may be from the "origin" repository at GitHub. It also tells you if you have local changes that you haven't yet committed. For more info type: git help status
  • git log - At any time, you may use this command to see a log of recent commits you've made to the current branch. For more info type: git help log
  • git diff - At any time, you may use this command to see differences of your current in progress work. For more info type: git help diff
  • git pull - Can be used instead of using git fetch followed by git merge. A "pull" does both a fetch and an automated "merge" in a single step.
  • git stash (See also: Stashing) - Allows you to temporarily "stash" uncommitted changes. This command is extremely useful if you want to do a "pull" or "merge" but were working on something else. You can temporarily "stash" what you are working on to perform the merge/pull, and then use git stash apply to reapply your stashed work.
  • git rebase (See also: Rebasing) - This tool is extremely powerful, and can be used to reorganize or combine commits that have been made on a local branch. It can also be used in place of a "merge" (in any of the situations described above). However, as it changes your commit history, you should NEVER USE REBASE ON ANY BRANCH THAT HAS BEEN PUBLICLY SHARED ON GITHUB. For more information, see Pro-Git's chapter on Rebasing and GitHub's 'rebase' page.
  • git cherry-pick - useful to grab a single commit into current branch from any of the local branches or remote branches added locally. A handy use-case is when we have a master branch and a bugfix branch (e.g. dspace-45_x) and you want a bugfix to go to both branches, you can commit to either branch, then switch to the other and execute "git cherry-pick [commit-hash]". Don't forget to push both branches, as usual. For details, see Getting a commit to multiple branches (backporting)

...

  • the "master" branch (in order for it to appear in the next major DSpace release)
  • the release branch, e.g. "dspace-45_x" (in order for it to appear in the next minor DSpace release)

...

  1. First, make sure you have the release branch (e.g. 'dspace-45_x') set up correctly in your local repo. It needs to be setup to "track" the branch in the "upstream" repo (read above on how to configure an upstream repository)

    Code Block
    # confirm you have set upstream correctly
    git remote -v
     
    # should output something like:
    # origin	git@github.com:yourgithubname/DSpace.git (fetch)
    # origin	git@github.com:yourgithubname/DSpace.git (push)
    # upstream	git@github.com:DSpace/DSpace.git (fetch)
    # upstream	git@github.com:DSpace/DSpace.git (push)
     
    # then check out the release branch
    git checkout dspace-45_x
     
    # note, the above command may not work for you, you may have to do this instead:
    # git checkout -b dspace-45_x upstream/dspace-45_x
     
    # should output something like:
    # Branch dspace-45_x set up to track remote branch dspace-45_x from upstream.
    # Switched to a new branch 'dspace-45_x'
  2. Create a Pull Request for the "master" branch. The easiest way to do this is to create it via GitHub.
  3. After your Pull Request has been reviewed and approved, make sure it is merged into the "master" branch.  The merger will result in two separate commits - the original change itself and the merge commit. Make sure you know the hash of the original commit.
  4. Use git cherry-pick to add the original commit to the release branch:
Code Block
# Make sure you are on your release branch (e.g. dspace-45_x)
git checkout dspace-45_x
# If you just merged to upstream/master, fetch the list of latest revisions from the upstream repo. not needed if you have the commit anywhere in the local repo.
git fetch upstream
# This is the hash of the original commit
git cherry-pick abc123def456
# check that it's correct
git log
# Finally, push from your local repo to the upstream repo branch
git push upstream dspace-45_x

 

Common DSpace Git/GitHub Issues

...