Commands
Command |
Description |
git --version |
Check git version |
git command -help / git command --help / git help --all |
Git help option for specific command / Git help option for all possible commands |
git config --list |
Configure user information for all local repositories |
git config user.name / git config --global user.name |
Configure user information for all local repositories |
git config user.email / git config --global user.email |
Configure user information for all local repositories |
git config user.password / git config --global user.password |
Configure user information for all local repositories |
git config --global core.autocrlf true |
Configure user information for all local repositories |
git config --global core.safecrlf true |
Configure user information for all local repositories |
git config --global color.ui auto |
Configure user information for all local repositories |
git config --global init.defaultbranch |
Configure user information for all local repositories |
pwd |
Print working directory |
mkdir directoryname |
Make a new directory |
cd directoryname |
Change the current working directory |
ls / ls -lart / dir |
List the files in the current working directory / List the files and directories in the current working directory / List the directories in the current working directory |
git init |
Turn an existing directory into a git repository |
git branch |
Check the current git branch |
touch .gitignore |
Make the .gitignore file |
git status / git status --short |
Check git status / Check the compact version of the status |
git add filename / git add --all / git add -A |
Add untracked file to staging environment |
git commit -m "what changed and when message" / git commit -a -m "what changed and when message" |
Add tracked/stage files to commit environment |
git log |
Check the history of commits |
git remote add origin url |
It specifies that you are adding a remote repository, with the specified url, as an origin to your local git repo |
git push --set-upstrem origin master / git pull --set-upstrem origin master |
To push our master branch to the origin url, and set it as the default remote branch / To pull our master branch to the origin url, and set it as the default remote branch |
git fetch origin |
Fetch gets all the change history of tracked branch/repo |
git log origin/master |
If changes tracked then check the change by log |
git diff origin/master |
Verify by showing the difference between our local master and origin/master |
git merge origin/master |
Merge our current branch master with origin/master |
git push origin / git pull origin |
It is Used to push all changes to our remote origin / It is used to pull all changes from a remote repository into the branch you are working on. |