An issue can be created in a git repo to track and plan a piece of work.
A pull request is a proposal to merge a set of changes from one branch into another. In a pull request, collaborators can review and discuss the proposed set of changes before they integrate the changes into the main codebase.
- Create a feature branch from the main branch.
- Commit the code to the feature branch.
- Got to Github and click on New Pull Request button.
- Verify the branch which the code will be merged to correct and is the intended branch to merge into like main.
- Verify the files and see if the correct code is being committed.
- Click on Create Pull Request button.
- Go to Your Repository: Navigate to the repository on GitHub where you want to add a collaborator.
- Settings: Click on the "Settings" tab, which is usually located at the top of the repository page.
- Manage Access: In the left sidebar, click on "Manage access."
- Invite a Collaborator: Click on the "Collaborators" link in the side navigation. Click on Add People button.
- Enter Username: Type the GitHub username or email address of the person you want to add as a collaborator.
- Send Invitation: Click "Add [username] to this repository" to send an invitation. The user will receive an email with a link to accept the invitation.
- Acceptance: Once the user accepts the invitation, they will have access to the repository based on the permissions you set.
Git is a version control system which manages and tracks changes to source code during software development. It allows multiple developers to work on the same project without overwriting each other's changes. Git is installed locally on your computer. It uses commands like git commit, git push, git pull, etc.
Github is a web-based platform. It hosts Git repositories online, providing a collaborative environment. It facilitates code sharing, collaboration, and version control through a web interface. Github offers additional tools like issue tracking, project management, and continuous integration. It is accessible via a web browser and integrates with Git.
git diff shows changes between your working directory and the staging area.
git diff --staged or git diff --cached shows changes between the staging area and the last commit.
git diff commit1 commit2 shows changes between two commits.
git diff [file] shows changes in a specific file.
This is the default branch created for each git repo. This branch is used to create all feature branches. The feature branches are merged back into the main branch through the pull requests. The main branch is used to send code to the environments.
h. Besides our initial commit if it is a new repository, should we directly push our changes directly into the main
branch?
No we should not push changes directly to the main branch. Feature branches should be created to commit code into. The feature branches should then be merged to the main branch through pull requests. This allows reviewers to review the code and provide feedback which can be corrected before committing the code to the main branch.