Thursday, September 24, 2026

Git and GitHub Notes by Megha (Pg3)

« Previously    Next »
# Git + GitHub Notes — Page 3

## Resolve Merge Conflict (Manually)

- Just open the file.
- Keep or delete the unwanted/conflicting changes.
- Save the file.
- Then run:


git add .
git commit -m "..."


## Git Stashing

**Stashing:** If you have made some changes but you need to do some emergency/other work, you can temporarily save your current changes using `git stash`.


git stash
git stash list
git status


- `git stash` — temporarily saves your current changes.
- `git stash list` — shows the saved stashes.
- `git status` — should show a clean working tree after stashing.
- When you want the changes back:


git stash pop


- `git stash pop` — brings back the stashed changes.

## Best Practices

1. Create an isolated branch for each feature.
2. Never develop directly on the `main` branch.
3. Delete merged branches.
4. Use meaningful branch names.
5. Keep branches short-lived and merge them as soon as possible.

## Git Tags

Git tags can be used to mark specific points/versions in the repository.

### Types of Tags

1. **Annotated tag**
   - Contains additional information/metadata.
   - Example:


git tag -a v1.0 -m "my release"


2. **Lightweight tag**
   - A simple tag pointing to a specific commit.
   - Example:


git tag v1.1


### Other Tag Command


git tag


- Lists the tags in the repository.

## Git Rebase


git rebase master


- Rebase can be used to replay the changes from one branch on top of another branch.
- This can help avoid unnecessary merge commits.
« Previously    Next »

No comments:

Post a Comment