- View the status of your working directory and staging area:
git status
- Stage changes (add files to the staging area):
git add filename git add .
- Commit changes with a message:
git commit -m "Your commit message"
- View the commit history:
git log
- Push changes to the remote repository:
git push origin branch-name
- Pull changes from the remote repository:
git pull origin branch-name
- Create a new branch:
git branch new-branch-name
- Switch to a branch:
git checkout branch-name
- Merge a branch into the current branch:
git merge branch-name
- Git will alert you if there are conflicts.
- Open the conflicting files and resolve the conflicts.
- After resolving, add the resolved files:
git add filename
- Commit the merge:
git commit -m "Resolved merge conflict"
- Git: A powerful tool for version control.
- GitHub: A platform for hosting Git repositories and collaborating.
- Basic Workflow:
- Initialize a repository.
- Connect to GitHub.
- Add, commit, push, and pull changes.
- Use branching and merging for collaborative work.
By mastering these basics, beginners can effectively start managing their projects and collaborating with others using Git and GitHub.