git config user.name 'foo'
git config user.email '[email protected]'
git --global user.name 'foo'
git status
git add .
git commit -m'My commit'
git log
git log -2
git log --oneline
git log --oneline -2
git log --before='2019-05-01T15:00:00'
git log --after='2019-05-01'
git log --since='2 days ago'
git log --after='2 days ago'
git log --author='smahi'
git help log
git checkout 123fce
git mv foo.txt bar.txt
git rm foo.txt
git diff --stage
git diff 123efe
To show the modification that happens between last commit and a defined one, including what happens in the specified one. (add ^
to the end of the hash number)
git diff 123efe^
git diff HEAD^
git diff 123456..345678
git commit --amend
Add the new file, then
git add .
git commit --amend
Make to changes to the file, then
git add .
git commit --amend
git reset HEAD foo.txt
git checkout -- foo.txt
git reset HEAD --hard
git reset HEAD^ --hard
First do a simulation (dry-run) by passing -n
git clean -d -n
Then do the following to remove the files/dirs
git clean -d -f
You can have braches for ( development, stage, and production)
git branch new_features
git checkout new_features
Or combine the two command like so
git checkout -b new_feature
git checkout master
git merge new_features
git branch -d new_features
Modify the files that has conflicts then add them to stage, then commit
Is another technic of merging two branches, In it the history is kept lineare and more clean.
git checkout new_feature
git rebase master
git checkout master
git merge new_features
git rebase -i master
Then in the commit file you w'll see some help. then merge
git checkout master
git merge new_features
Tilda ~
denote the previous n commit, in our example n = 3
git rebase -i HEAD~3
Tags are versions off your app.
git tag v-1.2
git tag
git checkout v-1.2
Push code to remote repo
git push origin master
To get latest changes we use fetch command
git fetch origin
git merge origin/master
Or do it in one command
git pull origin
git push -u origin new_features
git push -u origin -d new_features
git fetch --all
git fetch --all --prune