Git Commands
To initialize a repository:
-
git init
: Initialize a project as a Git repository.
To connect to a remote repository:
- Add or connect to a remote repository:
git remote add origin <link-to-github-remote-repo>
- View connected remote repositories:
git remote
To manage file status:
- View the status of files in your local repository (tracked, untracked, modified):
git status
- Stage modified or untracked files:
git add <file name>
Use git add .
to stage all unstaged files.
- Unstage files:
git reset
To commit changes:
- Commit staged files:
git commit
- Commit staged files with a commit message:
git commit -m "<commit message>"
To push changes:
- Push committed files to the remote repository in the specified branch. Use this command for the first push:
git push -u origin <branch-name>
- Push committed files to the remote repository:
git push
To fetch and pull changes:
- Fetch the most updated version of your local repository:
git fetch
- Pull the fetched information into your local repository, updating it to the most recent version of the remote repository:
git pull
Top comments (0)