Skip to content

Instantly share code, notes, and snippets.

@ranraj
Last active November 26, 2022 07:56
Show Gist options
  • Save ranraj/20da92a38c16020261ce to your computer and use it in GitHub Desktop.
Save ranraj/20da92a38c16020261ce to your computer and use it in GitHub Desktop.
Git help notes

Run this command first and do the git pull give your password, Thats all once given successful password it automaticaly store it. It will not ask again and again. git config credential.helper store

To avoid multiple branch push at the same time.

git config --global push.default simple

##Setup the repository

echo "# hackerrank" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/ranraj/hackerrank.git
git push -u origin master

git push --set-upstream origin master

##Setting up the local username for git repo

  • Local
git config --local user.name ranjithraj.d
git config --local user.email ranjithraj.d@gmail.com

history git pull origin master --allow-unrelated-histories

  • Global
git config --global user.name ranjithraj.d
git config --global user.email ranjithraj.d@gmail.com

##Remove some last commit

git reset command
git reset --hard commitid
git push -f origin commitid:branch
git stash
git rebase upstream/master
git push origin
git stash pop

git pull

git pull upstream main --rebase
git push

Guidence

Bookmarks : Connection pooling

Avoid entering passphrase

ssh-key-still-asking-for-password-and-passphrase

ssh-add ~/.ssh/id_rsa
ssh-add --apple-use-keychain ~/.ssh/id_rsa

Fork remote repo branch

git remote add other-user http://github.com/otheruser/repo
git fetch other-user
git checkout -b B4 other-user/B4
git push origin B4:B4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment