Table of Contents

New Developers Working Group

Useful Git Commands

Rebase

If your patch is behind current main, you'll need to rebase it.

  1. Open the git branch
  2. Type: git rebase origin/main –> rebases the current branch to main (you can do this when you have your branch checked out and changes committed, but have not yet pushed it)
  3. If there are merge conflict errors, type: git status
  4. Open the file with the problem in your preferred text editor (notepad++, vim, nano, etc.)
  5. Look for merge conflict markers in the file (>>>) and correct the problems
  6. Type: git add (problem file name)
  7. Repeat steps 4-6 for each additional problem file
  8. Type: git rebase --continue

Squash Commits

If you have multiple commits in your local branch that you'd like to combine:

  1. Use 'git log' to verify that the commits you want to combine are the most recent
  2. Type git rebase -i HEAD~2 (where 2 is the number of commits you wish to combine)
  3. Your text editor will open and should show both of the commits, for example:
    • pick 014e59c579 LP#1839359 Select element on login not accessible
    • pick 9de92lsi9a LP#1839359 Select element on login not accessible
  4. Change the word "pick" in the second line to either "fixup" or "squash" then save and close the file
    • squash –> merges commits, then allows amendment of commit message
    • fixup –> merges commits like squash does, but discards previous commit message
  5. Use "git commit –amend" if you need to edit the final commit message
  6. Push the changes up to your remote working directory as normal
    • git push working user/jdoe/lp1839359_login_select

If you've already pushed multiple commits up to your remote working git repository, you can still combine them:

  1. Follow the steps above, but when pushing, use "–force"
    • git push --force working user/jdoe/lp1839359_login_select

Common Bash Commands

Vim Text Editor

The vim text editor is built into the bash console (similar to notepad in Windows).

Vim opens in command mode, which allows a variety of functions, but does not allow direct editing.