filmov
tv
Mastering Git - Your Guide to Common Commands
Показать описание
Mastering Git: Your Guide to Common Commands
Initialize a new repository:
git init
Clone a repository:
git clone repository_url
Add changes to the staging area:
git add file
or
git add file1 file2 ...
Commit changes:
git commit -m "Your commit message"
View the status of your changes:
git status
View changes between commits:
git diff
Branching:
Create a new branch:
git branch branch_name
Switch to a branch:
git checkout branch_name
Create and switch to a new branch:
git checkout -b new_branch_name
List branches:
git branch
Merge changes from one branch to another:
git merge branch_name
Delete a branch:
git branch -d branch_name
Remote Repositories:
Add a remote repository:
git remote add origin repository_url
Fetch changes from a remote repository:
git fetch
Pull changes from a remote repository:
git pull origin branch_name
Push changes to a remote repository:
git push origin branch_name
Undoing Changes:
Discard changes in the working directory:
git checkout -- file
Undo the last commit -soft reset:
git reset --soft HEAD
Undo the last commit and discard changes -hard reset:
git reset --hard HEAD
Revert a commit -create a new commit that undoes changes:
git revert commit_sha
Logs and History:
View commit history:
git log
View a specific commit:
git show commit_sha
Miscellaneous:
Ignore files- add to .gitignore:
Create or edit a .gitignore file.
View Git configuration:
git config --list
Tagging - create and list tags:
git tag tag_name
git tag -l
Initialize a new repository:
git init
Clone a repository:
git clone repository_url
Add changes to the staging area:
git add file
or
git add file1 file2 ...
Commit changes:
git commit -m "Your commit message"
View the status of your changes:
git status
View changes between commits:
git diff
Branching:
Create a new branch:
git branch branch_name
Switch to a branch:
git checkout branch_name
Create and switch to a new branch:
git checkout -b new_branch_name
List branches:
git branch
Merge changes from one branch to another:
git merge branch_name
Delete a branch:
git branch -d branch_name
Remote Repositories:
Add a remote repository:
git remote add origin repository_url
Fetch changes from a remote repository:
git fetch
Pull changes from a remote repository:
git pull origin branch_name
Push changes to a remote repository:
git push origin branch_name
Undoing Changes:
Discard changes in the working directory:
git checkout -- file
Undo the last commit -soft reset:
git reset --soft HEAD
Undo the last commit and discard changes -hard reset:
git reset --hard HEAD
Revert a commit -create a new commit that undoes changes:
git revert commit_sha
Logs and History:
View commit history:
git log
View a specific commit:
git show commit_sha
Miscellaneous:
Ignore files- add to .gitignore:
Create or edit a .gitignore file.
View Git configuration:
git config --list
Tagging - create and list tags:
git tag tag_name
git tag -l