What do branch, commit, and PR mean on GitHub, and what are their uses? #181858
Replies: 5 comments
This comment was marked as off-topic.
This comment was marked as off-topic.
-
|
Commit Branch Pull Request (PR) How they work together Create a branch from the main branch Make changes and create commits Open a pull request Review and discuss the changes Merge the PR into the main branch What beginners should be careful about Avoid committing directly to the main branch Use clear, descriptive commit messages Keep commits small and focused Review changes before opening a pull request Never commit sensitive information like API keys or passwords This workflow is the foundation of modern collaborative software development and is used across open-source and professional projects. |
Beta Was this translation helpful? Give feedback.
-
|
Commit: A saved snapshot of code changes. It records what changed and when. Typical workflow: |
Beta Was this translation helpful? Give feedback.
-
|
Commit = record of changes Branch = isolated workspace PR = request to merge your changes into the main project Together, they allow safe, organized, collaborative software development.
A commit is like saving a change in your project, but with history. Meaning: A commit is a snapshot of your code at a specific moment. Every commit has: The exact code changes A message describing the change A unique ID (hash) Purpose / Use: Track changes over time Explain what was changed and why Allow rollback (go back to previous versions) Help collaborators understand your edits Example: “Fix login bug”, “Add homepage UI”, “Update README” Beginner Tips: Write clear commit messages (so others can understand) Make small commits, not huge ones Never commit secrets or passwords
A branch is like having a “copy” of your code that you can edit without breaking the main version. Meaning: A branch is a parallel line of development. Purpose / Use: Work on new features safely Experiment without affecting the main project Collaborate with others: each person works on their own branch Prevent breaking the production code (main / master) Example: main — production-ready code feature/login-page — developer works on login page here bugfix/header-align — fix UI bug here Beginner Tips: Never develop directly on main. Use descriptive names for branches. Delete branches after merging to keep the project clean.
A PR (pull request) is a request to merge your changes from one branch into another (usually into main). Meaning: You finished working on a branch and now want your changes reviewed and added to the main project. Purpose / Use: Code review: teammates check your work Discuss changes Run automated tests Ensure code quality Safely merge features into the stable main project Example workflow: Create branch → feature/add-profile Make commits on that branch Open a PR on GitHub Review comments → fix issues Merge PR → changes go into main |
Beta Was this translation helpful? Give feedback.
-
|
A branch creates an isolated environment where you can develop features or fix bugs without affecting the main project. This allows multiple developers to work simultaneously without interference. A commit acts as a saved checkpoint in that branch, preserving a version of your changes to build a history you can review or revert if errors occur. When your work is ready for integration, a pull request notifies maintainers to review your code before merging it. Since you're still new you should always create a new branch for any edits to ensure the main codebase remains stable. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
What do branch, commit, and PR mean on GitHub, and what are their uses?
When browsing GitHub projects, I often see terms like "branch", "commit history", and "PR" but can’t understand their meanings or uses at all. I want to know the roles of these functions in actual development (such as whether they are used for collaborative work or code modifications) and what beginners need to pay attention to when using them to avoid accidental operations affecting the project.
Beta Was this translation helpful? Give feedback.
All reactions