MuhammadAliashraf/A-list-of-Git-commands

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation



DescriptionCommand
Configure the author name.git config --global user.name "<username>"
Configure the author email address.git config --global user.email <email address>
DescriptionCommand
Initialize a local Git repositorygit init
Create a local copy of a remote repositorygit clone ssh://[email protected]/<username>/<repository-name>.git
DescriptionCommand
Check statusgit status
Add a file to the staging areagit add <file-name.txt>
Add all new and changed files to the staging areagit add -A or
git add .
Commit changesgit commit -m "<commit message>"
Remove a file (or folder)git rm -r <file-name.txt>
DescriptionCommand
View changesgit log
View changes (detailed)git log --summary
View changes in one line (briefly)git log --oneline or
git log --pretty=oneline or
git log --pretty=short
DescriptionCommand
List of all commit with commit id and commit message)git log --oneline
Return to previous commitgit checkout<commit id>
Revert commit (undo one particular commit)git revert <commit id>
Reset to previous commit (remove history of all commit after )git reset --hard <commit id>
Stop a file being trackedgit rm --cached <file/folder>
Restore a file to a previous commitgit checkout <file/to/restore>
DescriptionCommand
List branches (the asterisk denotes the current branch)git branch
List all branches (local and remote)git branch -a
Create a new branchgit branch <branch name>
Create a new branch and switch to itgit checkout -b <branch name>
Clone a remote branch and switch to itgit checkout -b <branch name> origin/<branch name>
Rename a local branchgit branch -m <old branch name> <new branch name>
Switch to a branchgit checkout <branch name>
Switch to the branch last checked outgit checkout -
Discard changes to a filegit checkout -- <file-name.txt>
Delete a branchgit branch -d <branch name>
Delete a remote branchgit push origin --delete <branch name>
Preview changes before merginggit diff <source branch> <target branch>
Merge a branch into the active branchgit merge <branch name>
Merge a branch into a target branchgit merge <source branch> <target branch>
Stash changes in a dirty working directorygit stash
Remove all stashed entriesgit stash clear
DescriptionCommand
Push a branch to your remote repositorygit push origin <branch name>
Push changes to remote repository (and remember the branch)git push -u origin <branch name>
Push changes to remote repository (remembered branch)git push
Push changes to remote repository all branchgit push --all
Push changes to remote repository (Force)git push -f
Delete a remote branchgit push origin --delete <branch name>
Update local repository to the newest commitgit pull
Pull changes from remote repositorygit pull origin <branch name>
Add a remote repositorygit remote add origin ssh://[email protected]/<username>/<repository-name>.git
Set a repository's origin branch to SSHgit remote set-url origin ssh://[email protected]/<username>/<repository-name>.git

follow

About

This collection includes all essential Git commands to help you manage your repositories effectively.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published