13. Apr 2020 |

My little git helper

Find branch

git branch -a | grep “minu-andmed”
git checkout ABC-123-minu-andmed

git config --list – see user info

git add -u – add modified and deleted files

Rollback and unstage

Use git checkout HEAD -- <file> … to discard changes in working directory
Use git reset HEAD <file> to unstage added files.

Merge

  1. Checkout destination branch
  2. git pull origin TASK-514 / or git merge TASK-514 (ref)
  3. Resolve conflicts
  4. Push

…or create a new repository on the command line

echo “# icd0008-2020f-05” >> README.md
git init
git add README.md
git commit -m “first commit”
git branch -M main
git remote add origin https://github.com/robineero/icd0008-2020f-05.git
git push -u origin main

…or push an existing repository from the command line

git remote add origin https://github.com/robineero/icd0008-2020f-05.git
git branch -M main
git push -u origin main

“Remote origin already exists” error (viide): git remote set-url origin https://github.com/your/repository

Which git is: git remote -v

Git not working

https://stackoverflow.com/questions/25436312/gitignore-not-working/25436481

The files/folder in your version control will not just delete themselves just because you added them to the .gitignore. They are already in the repository and you have to remove them. You can just do that with this:

(Remember to commit everything you’ve changed before you do this.)

git rm -rf --cached .
git add .

This removes all files from the repository and adds them back (this time respecting the rules in your .gitignore).

Leave a Reply

Your email address will not be published. Required fields are marked *