Git cheetsheet (old)
ADD SECOND REPO
git remote add bydos-asa http://gitlab.d0.vsw.ru:8888/bydos/ansible_asa.git git remote show
cd /home/vm/myplatform/
git init
git remote add origin "https://github.com/gorokhovdenis/ansible.git" git remote set-url origin https://github.com/USERNAME/REPOSITORY.git git remote -v
git pull https://github.com/gorokhovdenis/ansible.git master git push https://github.com/gorokhovdenis/ansible.git master
git status git add ansible.cfg #add 1 file strictly
git add -A #all git commit -m "from VM"
git commit -am "comment" #commit several files
Branches
git branch firstbranch git checkout firstbranch
#switch to branch
next changes will be in firsbrunch
you can ls in windows in git-bash in branch
git merge firstbranch
rebase better for history git rebase master
git pull https://github.com/gorokhovdenis/ansible.git master git push https://github.com/gorokhovdenis/ansible.git master
git commit -a -m "resolve conflict"
����� ������� ����� � github � ��������� ��������
git reset apic.yml git rm --cached apic.yml
git stash
git stash apply
git log -p -2
#���������� 2 ��������� ������ � �������� ��������� git checkout 4c1a766cab272f9e0865e3190e50a11920242f4c
���������� ������ ��������
git log
���������� ������ ������, ������� ����������� ������� ������
git branch
Detached head means you are no longer on a branch, you have checked out a single commit in the history (in this case the commit previous to HEAD, i.e. HEAD^).
If you want to delete your changes associated with the detached HEAD You only need to checkout the branch you were on, e.g.
git checkout master
�������� ��������� ����� �� ����� � ������� github (��� ���� ������ �� ��� ���� � �����. ������� �����!!!) git fetch --all git reset --hard origin/master
��� ���� �� ���������� � ������ �����:
git reset --hard origin/your_branch
���������: ������� git fetch ��������� ��������� ������ ������ �� ���������� �����������, �� ������� ���-���� ���������� ��� ���������������� (merge ��� rebase). ����� git reset ��������� ������� ������ ��, ������� �� ������ ��� ��������. ����� --hard �������� ��� ����� � ����� ������� ����� � ������������ � ������� � origin/master
ssh key login
ssh-keygen -t rsa -C "gorokhov@gmx.com"
copy content of file ~/.ssh/id_rsa.pubsudo apt-get install xclip xclip -sel clip < ~/.ssh/id_rsa.pub
ssh -T git@github.com
#(passwd 123qwe)
add key in githab Settings-> SSH and GPG-keys -> New SSH key (paste and save)
git remote set-url origin git@github.com:gorokhovdenis/ansible.git
now we can just
git push
��� �������� ����� �� git-����������� ��� ��� ����������� ��������:
git rm --cached mylogfile.log
��� �������� ����� (����������) ����� ������� ���:
git rm -r --cached folderName
� ��� ����, ����� �������� �� �����������, ����� �������� ���� ��� ����� � .gitignore.
rollback git log git checkout 1209f65e049eb783aef6e40c2021b2ea9e9e3379
Git Patch mod
If there is come problems while doing merge it can be rolled beck
git reset --merge
Last updated
Was this helpful?