Tech C**P
14 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
When you commit to git, then you push and get rejected:

$ git push
To my_repo:~/my_project.git
! [rejected] dev -> dev (fetch first)
error: failed to push some refs to 'my_repo:~/my_project.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

To prevent merging with your local and making your git history filthy, reset head to the latest commit (head~1):

$ git reset HEAD~1
Unstaged changes after reset:
M another_file_here.py
M some_file_here.py

Now git pull and the commit again and push. The world is cleaner now.

#git #reset_head #merge #repository
Disable the below message in gitlab if your are annoyed with it like me:
remote:
remote: To create a merge request for dev, visit:
remote: https://repo.alohi.ch/alohi/backend/affogato/merge_requests/new?merge_request%5Bsource_branch%5D=dev
remote:
Go to your project settings and uncheck:
Display link to create/view merge request on push

#gitlab #merge_request #push
If you are using python 3.5 or greater and want to merge to dictionaries:
>>> a = {'a': 1}
>>> b = {'b': 2}
>>> {**a, **b}
{'a': 1, 'b': 2}

That's it! You have merged 2 dictionaries in the most simplest way ever. :)

If you are using python 2.7 or python 3.4 or less, merge dictionaries as below:
def merge_two_dicts(a, b):
c = a.copy()
c.update(b)
return c

python #python3 #merge #dictionary