1. Create a New Issue

  • Ensure the issue title is specific and meaningful
  • Clearly describe the problem to solve or feature to implement

2. Create a New Branch

  • Use the command lines automatically generated by Github to create and switch to the new branch
  • Typical format:
    1
    git checkout -b feature/your-branch-name

3. Development

  • Work on your new branch
  • If anything goes wrong, reset to initial version:
    1
    git reset --hard HEAD

4. Save Changes

  • Execute these commands in order:
    1
    2
    3
    git add .
    git commit -m "your commit message"
    git push origin

4.1 Handling Merge Conflicts

If you encounter merge conflicts:

  • First, pull the latest changes from the main branch:

    1
    git pull origin main
  • Resolve conflicts in your code editor:

    • Look for conflict markers (<<<<<<, =======, >>>>>>>)
    • Choose which changes to keep
    • Remove conflict markers
  • After resolving conflicts:

    1
    2
    3
    git add .
    git commit -m "resolve merge conflicts"
    git push origin

4.2 Using Rebase

Alternative approach using rebase:

  • Get the latest changes from main:

    1
    git fetch origin main
  • Start the rebase:

    1
    git rebase origin/main
  • If conflicts occur during rebase:

    • Resolve conflicts in each commit
    • After resolving:
      1
      2
      git add .
      git rebase --continue
    • If you need to abort the rebase:
      1
      git rebase --abort
  • Force push after successful rebase:

    1
    git push origin --force-with-lease

5. Create a Pull Request

  • Create a Pull Request on Github
  • Wait for team leader’s approval
  • Merge into main branch after approval

6. Release & Tagging

6.1 Creating a Release

  • Create a version tag:

    1
    git tag -a v1.0.0 -m "Release version 1.0.0"
  • Push the tag to remote:

    1
    git push origin v1.0.0

6.2 Tag Management

  • List all tags:

    1
    git tag
  • View tag details:

    1
    git show v1.0.0
  • Delete local tag:

    1
    git tag -d v1.0.0
  • Delete remote tag:

    1
    git push origin --delete v1.0.0

7. Useful Git Commands

7.1 Checking Status & History

  • Basic Status Commands:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    # Check current status
    git status

    # View commit history
    git log
    git log --oneline # Compact view
    git log --graph # Tree view

    # Check differences
    git diff # Working directory vs staging
    git diff --staged # Staging vs last commit

7.2 Stashing Changes

  • Stash Operations:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    # Save changes temporarily
    git stash

    # List stashes
    git stash list

    # Apply most recent stash
    git stash pop

    # Apply specific stash
    git stash apply stash@{n}

7.3 Branch Management

  • Branch Commands:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    # List all branches
    git branch

    # Switch to another branch
    git checkout branch-name
    # or
    git switch branch-name

    # Delete local branch
    git branch -d branch-name

    # Delete remote branch
    git push origin --delete branch-name

7.4 Undoing Changes

  • Reset and Revert:

    1
    2
    3
    4
    5
    6
    7
    8
    # Undo last commit (keep changes)
    git reset --soft HEAD^

    # Discard changes in working directory
    git checkout -- file-name

    # Revert a commit
    git revert commit-hash

8. Done! 🎉 Time to play Hearthstone! 🤪