Skip to content

Instantly share code, notes, and snippets.

@nivb52
Last active November 25, 2021 13:20
Show Gist options
  • Select an option

  • Save nivb52/551303a144588787fe24a5587cd0e0e0 to your computer and use it in GitHub Desktop.

Select an option

Save nivb52/551303a144588787fe24a5587cd0e0e0 to your computer and use it in GitHub Desktop.
Git
## INIT
echo "# starting new great project" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/nivb52/--repo--name--.git
git push -u origin main
## REBASE
$ git log --oneline
one line for git commot msgs
$ git rebase -i HEAD~3
get commits from head (current comment) till minus 3 to make the interactive change
#example reword *chane the comment)
popup window we will see commands in the comments
andother pop up window and then we can make the changes
# another use case example is squash: (combine)
this work as the squash with the previous commit
## CHERRY PICK
useful when commiting to thewrong branch accedentily
$git cherry-oick <<has-of-commit>>
to complete the removing of the commit from the main branch
we need to delete it so::
$git reset --hard HEAD~1
#Reflog
$git reflog
getting the log history for the commits
mark the hash you want and do the action you want
even deltes can be restored
#recover branch
#git branch <<branch-nmae>> <<hash>>
$Submodules
# logs search
$git relog <<command>>
command : --before --after
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment