githelpdoc
githelpdoc
changes, committing them, pushing to the repository, and creating pull requests. Below is
a step-by-step guide to walk you through the entire process:
To check the status of your repository and see the current branch:
git status
git branch
Command:
git checkout -b <branch_name>
3. Making Changes
Now that you're in your new branch, make the necessary changes in the code using your code
editor.
4. Adding Changes
To stage the changes you’ve made:
git add .
5. Committing Changes
Once the changes are staged, commit them with a meaningful message:
Command:
git commit -m "Describe your changes briefly, e.g., 'Added
login functionality'"
Command:
git push origin <branch_name>
Steps:
1. Compare your branch with the main branch (or the branch you want to merge into).
2. Add a title and description for your PR to explain your changes.
3. Click Create Pull Request.
GitHub will automatically update the pull request with the new changes.
Command:
git checkout main
git pull origin main
If your branch is behind the main branch, you can rebase or merge the changes into your
branch:
Locally:
git branch -d <branch_name>
Remotely:
git push origin --delete <branch_name>
Example Workflow:
By following this process, you and your classmates can collaborate effectively while
minimizing merge conflicts. Let me know if you need help with any step!
To see all branches in the remote repository, you can use the following command:
git branch -r
origin/main
origin/problem_image_upload
If you want to create a local branch that tracks the remote problem_image_upload branch,
you need to check it out:
• git checkout -b: Creates a new local branch and switches to it.
• problem_image_upload: The name of the new local branch.
• origin/problem_image_upload: Specifies the remote branch to track.
* problem_image_upload
main
Now you have both branches locally. If you switch back to main or need to work with
another branch, you can use:
If you want to fetch all branches from the remote repository, use:
git fetch
This will ensure all remote branches are available locally for tracking. To see both remote
and local branches together:
git branch -a
* main
remotes/origin/main
remotes/origin/problem_image_upload