[go: up one dir, main page]

0% found this document useful (0 votes)
1 views3 pages

Git and GitHub Basic Commands

Uploaded by

chandankrs132
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views3 pages

Git and GitHub Basic Commands

Uploaded by

chandankrs132
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Git and GitHub Basic Commands

Git and GitHub Basic Commands

1. git init

Initializes a new Git repository in the current directory.

2. git clone <repository_url>

Clones an existing repository from GitHub to your local machine.

3. git status

Displays the status of changes in your working directory.

4. git add <file>

Stages changes to a specific file for the next commit.

5. git add .

Stages all changes (including new, modified, and deleted files) for the next commit.

6. git commit -m "<message>"

Commits staged changes with a descriptive message.

7. git push

Pushes local commits to the remote repository (e.g., GitHub).


8. git pull

Fetches and merges changes from the remote repository to your local repository.

9. git remote add origin <repository_url>

Links a local repository to a remote repository (usually GitHub).

10. git remote -v

Displays the URLs of remote repositories associated with the local repository.

11. git fetch

Fetches updates from the remote repository without merging.

12. git branch

Lists all local branches in your repository.

13. git checkout <branch>

Switches to the specified branch.

14. git merge <branch>

Merges a branch into the current branch.

Steps to Push Code to GitHub

1. Initialize Git Repository (If not done already)

If you haven?t initialized a Git repository yet, run:

git init
2. Add Remote Repository (Only once)

Link your local repository to a remote GitHub repository. Run:

git remote add origin <repository_url>

3. Stage Changes

Add all the changes to the staging area:

git add .

4. Commit Changes

Commit the staged changes with a message:

git commit -m "Your commit message"

5. Push Changes to GitHub

Push the committed changes to the remote repository on GitHub:

git push -u origin main

6. Verify Push

Go to your GitHub repository and check if the code has been uploaded successfully.

You might also like