Github Collaboration Notes
Github Collaboration Notes
For collaboration
1
ABOUT THE COMMANDS
This command clones an existing Git repository from a remote location, typically a hosting
service like GitHub or GitLab. <repo link> is the URL for the repository you want to clone.
This command clones the repository from GitHub to your local machine. After this command,
you will have a local copy of the repository in a directory named your-repo.
2. git add .
This command adds all the files in your current working directory to the staging area. The
staging area is like a holding zone where you tell Git which files you want to include in your
next commit.
This command creates a snapshot of the files in your staging area and stores it permanently in
the Git repository history. The -m flag lets you specify a commit message, which is a brief
description of the changes you're making. In your example, it instructs you to replace "enter
file name" with a description relevant to your changes.
This creates a new commit in the Git history, capturing the state of the project at that point.
This command pushes your local commits to the remote repository. "origin" is the default
remote name for the repository you cloned from (e.g., GitHub or GitLab).
2
Pushing requires write access to the remote repository. You might need to provide your
credentials in the terminal when running this command for the first time.
The -u flag in the command sets the upstream branch, which is a reference to the same branch
on the remote repository that you're pushing your commits to. However, it's generally not
recommended to use -u with the first push, especially for public repositories, as it can overwrite
remote branches unintentionally. It's safer to omit -u for the initial push and set the upstream
branch manually later if needed.
In our example, assuming you've made changes, added them to staging, and created a commit
with a message, you could run:
This pushes your local commits to the "master" branch of the "origin" remote repository (which
likely points to GitHub or GitLab in this case).
3
commands for owners,
(who is merging the code from the modifiers)
1. Use git fetch
(for getting the modified file in your local machines)
asterisk (*) symbol is indeed used to indicate the current branch you're working on in
most Git tools. git push -u origin (filename without bracket)
4
• git fetch: This command retrieves the latest changes from the remote repository (like GitHub
or GitLab) without merging them into your local branch. It essentially downloads new
information about the remote branches but doesn't modify your working directory.
git switch filename : This command attempts to switch to a branch named "filename".
• git switch main: This correctly switches your local working directory to the "main" branch,
assuming that's the branch you want to work on.
• git merge filename (assuming it's a branch name): This command attempts to merge the
changes from the branch named "filename" into your current branch ("main" in this case). If
there are no conflicts (changes made to the same lines of code in both branches), the merge
will be successful.
• git push origin main: This command pushes your local "main" branch, including the merged
changes (if any), to the remote repository named "origin" (typically points to GitHub or
GitLab).