Skip to main content

Command Palette

Search for a command to run...

Github: Working with branches

Published
•2 min read•View as Markdown
Github: Working with branches
S

Full Stack Developer | HTML,CSS, Javascript, WordPress | @sinapradip

To collaborate effectively with your frontend developer using Git and GitHub, you can follow these steps:


1. Create a New Branch for Your Work

Each developer should work on their own branch to avoid conflicts and keep the main branch stable.

  1. Create a new branch:

     git checkout -b backend-feature
    

    Replace backend-feature with a meaningful branch name (e.g., backend-auth, backend-api).

  2. Push the branch to GitHub:

     git push -u origin backend-feature
    

2. Commit and Push Your Changes

  1. Stage your changes:

     git add .
    
  2. Commit your changes:

     git commit -m "Implemented backend authentication"
    
  3. Push your changes to the branch:

     git push
    

3. Notify the Collaborator

Once your changes are pushed, notify the frontend developer (Nirajan Malla) to review your branch.


4. Create a Pull Request (PR)

  1. Go to your GitHub repository.

  2. Switch to the branch you just pushed (e.g., backend-feature).

  3. Click on "Compare & pull request".

  4. Add a title and description for the PR.

  5. Assign the PR to Nirajan Malla for review.

  6. Click "Create pull request".


5. Review and Merge

  1. Nirajan can review your PR and suggest changes if needed.

  2. Once approved, you or Nirajan can merge the PR into the main branch.


6. Pull Changes from main

After merging, make sure to pull the latest changes from the main branch to keep your local repository up-to-date:

git checkout main
git pull origin main

7. Repeat for Frontend Developer

Nirajan can follow the same process:

  1. Create a new branch (e.g., frontend-feature).

  2. Push changes to the branch.

  3. Create a PR for you to review and merge.


Best Practices

  1. Branch Naming Convention:

    • Use descriptive branch names like backend-auth, frontend-ui, etc.
  2. Commit Messages:

    • Write clear and concise commit messages (e.g., Added JWT authentication).
  3. Pull Regularly:

    • Regularly pull changes from the main branch to avoid conflicts:

        git pull origin main
      
  4. Code Reviews:

    • Always review each other's PRs before merging.
  5. Use GitHub Issues:

    • Create GitHub issues to track tasks and assign them to the appropriate developer.

By following this workflow, you and Nirajan can collaborate efficiently while maintaining a clean and stable codebase.