This is me learning some git, Python syntax, and PEP8 style guide.
git fetch originRetrieve changes from remote repository without merging to local.git pull origin mainMerges remotemainbranch with your current branch.git statusSee Git info such as your current branch, and files that have been changed/need commits.git checkout <branch-name>Change your current branch.git add <file_name>orgit add .Stage file for commit or stage all files for commit.git commit -m "concise message"Commit project changes that will be pushed.git push <branch-name>Push changes from current local branch to origin branch.git checkout -b <branch-name>Create new local branch.git branch -d <branch-name>Delete local branch.git push -u origin <branch-name>Push local branch to remote repository. ("Creates" remote branch.)git push origin --delete <branch-name>Delete remote branch.
-
Fetch Updates:
- Begin by fetching any changes that might have occurred in the remote repository since your last session:
git fetch origin- This retrieves any new commits or branches without merging them into your local branches, allowing you to review them first.
- Begin by fetching any changes that might have occurred in the remote repository since your last session:
-
Review Updates (if applicable):
- If working in a collaborative environment, check for new commits or branches using:
git branch -ato see all local and remote branches.git log main..origin/mainto view commits onorigin/mainthat aren't in your localmainbranch.
- Assess whether you need to merge or rebase to incorporate these changes into your local work.
- If working in a collaborative environment, check for new commits or branches using:
-
Checkout Appropriate Branch:
- Ensure you're working on the correct branch:
git checkout mainto switch to themainbranch.
- Create a new branch for new features or bug fixes to isolate your work:
git checkout -b <branch-name>- Use prefixes to categorize branches and instantly understand their purpose.
- e.g.,
feature/bugfix/hotfix/release/docs/test/
- e.g.,
- After the prefix, add a descriptive suffix that clarifies the specific change or feature.
- e.g.,
feature/add-login-systembugfix/crash-on-startuprelease/v1.2.0
- e.g.,
- Use prefixes to categorize branches and instantly understand their purpose.
- Ensure you're working on the correct branch:
-
Pull Changes (if necessary):
- If you need to incorporate remote changes into your local branch, use:
git pull origin mainto fetch and merge changes from the remotemainbranch into your localmainbranch.
- If you need to incorporate remote changes into your local branch, use:
-
Review Status:
- Use
git statusto check the status of your working directory, including untracked files, modified files, and file stages. This helps you understand what changes you've made and what needs to be committed.
- Use
- Committing Changes:
- Stage relevant changes: Ensure you've staged all the changes you want to track before committing.
Use
git add <file_name>to stage specific files orgit add .to stage everything. - Write informative commit messages: Summarize the changes you made in a clear and concise message. Mention the issue fixed, feature added, or task completed. A good message helps understand the code's evolution later.
- Create multiple commits for significant work: If you worked on various things throughout the day, consider splitting them into separate commits with focused messages. This allows for finer-grained rollback if needed.
- Stage relevant changes: Ensure you've staged all the changes you want to track before committing.
Use
2.Organizing Branches
- Push your work to remote: After committing, push your local changes to the remote repository
(e.g., GitHub) using
git push <branch-name>. This ensures your work is backed up and accessible to others. - Switch to
mainbranch: If you were working on a feature branch, switch back to the main branch usinggit checkout main. This ensures you're working on the current codebase when starting your next session. - Clean up local branches (optional): If you have completed feature branches and pushed them to remote, consider
deleting them locally using
git branch -d <branch-name>. This keeps your local environment tidy.
- Review your changes: Before committing, take a moment to review your code and messages to ensure everything is correct and well-documented.
- Commit Frequently: Make small, focused commits with clear messages to track progress and facilitate collaboration.
- Pull Often: Pull changes from the remote repository regularly to stay up-to-date and avoid merge conflicts.
- Utilize Branching: Use branches for features, bug fixes, and experiments to isolate changes and maintain a clean
mainbranch. - Address Conflicts Proactively: Resolve merge conflicts as soon as they arise to prevent accumulation and more complex issues.
- Communicate with Collaborators: Discuss changes and branching strategies with teammates to ensure a smooth workflow and avoid misunderstandings.