Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
12 views

Github Collaboration Notes

Notes

Uploaded by

sirisweety2002
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Github Collaboration Notes

Notes

Uploaded by

sirisweety2002
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Topic -1 Github commands

For collaboration

Step1. Create your repository


St2- click on settings
St3- go to collaboration section
St4- invite the peoples you want to collaborate

commands for collaborators,


( who is cloning your code)
1. Use git clone for cloning the repository in your pc
git clone <repo link>
2. Modify the code
3. After completing modifying process, you have to
commit and push the code
git add .
git commit -m “enter file name”
4. Now push the code in the central database
git push -u origin (filename without bracket)

1
ABOUT THE COMMANDS

1. git clone <repo link>

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 stages all the changes in the current directory.

3. git commit -m "enter file name"

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.

4. git push -u origin (filename without bracket)

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)

2. Now, switch to the branch where the code is modify


git switch filename

3. Now , for merging the code switch to the main/master


branch
Using git switch main

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. Now to merge the code use,


git merge filename
git push origin main

ABOUT THE COMMANDS

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).

You might also like