Skip to content

Instantly share code, notes, and snippets.

@ufukomer
Last active July 7, 2020 11:08
Show Gist options
  • Save ufukomer/c52de8b72811cc7d5eed to your computer and use it in GitHub Desktop.
Save ufukomer/c52de8b72811cc7d5eed to your computer and use it in GitHub Desktop.
Git Commands

Clone respotory to your pc

$ git clone 'ssh clone url'

Push

$ git add .
$ git commit -m "Your message"
$ git push -u origin master

Force push

$ git push origin master --force

Pull

$ git pull

Remove commit

$ git reset --hard HEAD~1
$ git push origin HEAD --force

Remove file from repositery (not from local)

$ git rm -r --cached some-directory
$git commit -m 'Remove the now ignored directory "some-directory"'
$ git push origin master

md syntax

https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet https://confluence.atlassian.com/display/STASH/Markdown+syntax+guide https://github.com/tchapi/markdown-cheatsheet/blob/master/README.md

remove accidently pushed (.idea) folder

$ echo '.idea' >> .gitignore
$ git rm -r --cached .idea
$ git add .gitignore
$ git commit -m '(some message stating you added .idea to ignored entries)'
$ git push

edit old pushed commit message

http://schacon.github.io/history.html then run: $ git push --force

update forked repository

Git rebase

  • $ git rebase develop

  • $ git add -u

  • $ git rebase --continue

  • $ git push --force origin sample(your branch name)

Stackoverflow

Git Reset Origin

git fetch --all
git reset --hard origin/master

Stackoverflow

Clone with specific commit

git clone -n <repo_name> 
git checkout <commit_sha>

Directory hard reset (have not tried yet)

git checkout -- a // a is directory

Empty commit

git commit --allow-empty -m "Trigger"
git push --force

Rename local branch

git branch -m <old_name> <new_name>

Recommit unpushed commit

https://stackoverflow.com/a/19859644/3650955

Print short hash of last commit

git rev-parse --short HEAD

Delete merged branches

git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d

Ignore changes

git update-index --assume-unchanged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment