0% found this document useful (0 votes)
2 views

GitHub_commands

This document provides a comprehensive guide on using GitHub Git Bash commands for team collaboration on Windows. It covers initial setup, cloning repositories, working with branches, making changes, pushing and pulling updates, resolving merge conflicts, and best practices for collaboration. Key commands and their functions are outlined to facilitate effective version control and teamwork.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

GitHub_commands

This document provides a comprehensive guide on using GitHub Git Bash commands for team collaboration on Windows. It covers initial setup, cloning repositories, working with branches, making changes, pushing and pulling updates, resolving merge conflicts, and best practices for collaboration. Key commands and their functions are outlined to facilitate effective version control and teamwork.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

GitHub Git Bash Commands for Team Collaboration (Windows)

1. Initial Setup (One-time Configuration)

-----------------------------------------

git config --global user.name "Your Name"

git config --global user.email "[email protected]"

git config --global core.editor "nano" # or "code" or "notepad"

git config --list # Check current config

2. Clone a Repository

---------------------

git clone https://github.com/username/repo.git

cd repo

3. Working with Branches

------------------------

git branch # List branches

git branch branch-name # Create new branch

git checkout branch-name # Switch to branch

git checkout -b new-branch # Create and switch to new branch

git branch -d branch-name # Delete local branch

git push origin --delete branch-name # Delete remote branch

4. Making Changes

-----------------

git status # See changes

git add filename # Stage file


git add . # Stage all files

git reset filename # Unstage file

git commit -m "Your commit message" # Commit changes

5. Pushing and Pulling Changes

------------------------------

git push origin branch-name # Push to remote

git pull origin branch-name # Pull from remote

git fetch origin # Fetch without merge

git merge origin/branch-name # Merge fetched changes

6. Synchronizing with Team

--------------------------

git fetch # Get latest refs from origin

git pull --rebase origin branch-name # Rebase your work (cleaner history)

7. Resolving Merge Conflicts

----------------------------

git status # See conflicted files

# Manually resolve conflicts in files

git add filename # Mark as resolved

git commit # Finalize the merge

8. Stashing Changes

-------------------

git stash # Save uncommitted changes

git stash list # Show stash list


git stash apply # Reapply latest stash

git stash pop # Apply and remove stash

git stash drop # Remove a stash

9. Viewing History and Logs

---------------------------

git log # Full history

git log --oneline --graph --all # Compact graph

git diff # See unstaged changes

git diff --cached # See staged changes

10. Tagging Versions

--------------------

git tag v1.0 # Create tag

git tag # List tags

git push origin v1.0 # Push tag to remote

git push origin --tags # Push all tags

11. Undoing Mistakes

--------------------

git checkout -- filename # Discard changes to file

git reset HEAD~1 # Undo last commit (keep changes)

git revert <commit-id> # Revert a specific commit

git clean -fd # Remove untracked files/folders

12. Collaboration Best Practices

--------------------------------
- Always `pull` before you `push`.

- Create a branch for each feature/bugfix.

- Use clear commit messages.

- Avoid committing directly to `main`/`master`.

You might also like