Git push Command
In this page:
git push remote_name branch_name
git push -u remote_name branch_name
git push --all remote_name
Git Push क्या है?
git push आपकी current local branch पर commits को एक remote repository पर matching branch में upload करता है, आपके काम को उस remote तक access रखने वाले हर किसी के लिए visible और available बनाते हुए।
उदाहरण: What is Git Push?
git push origin main
Remote में एक Branch Push करना
पहली बार जब आप एक बिल्कुल नई local branch push करते हैं, git push -u origin <branch> (या --set-upstream) इसे same नाम की एक remote branch से link करता है, इसलिए उस branch से हर future push या pull बिना extra arguments के एक plain git push हो सकता है। upstream link एक बार set हो जाने के बाद, उसी branch की बाद की pushes को सिर्फ git push चाहिए (या explicitly git push origin <branch>), क्योंकि Git को पहले से पता है कि कौन सी remote branch update करनी है -- scripts या CI में branch को explicitly नाम देना अभी भी उपयोगी है जहाँ current branch assume नहीं होनी चाहिए।
उदाहरण: Pushing a Branch to Remote
git push -u origin feature-login
सभी Branches Push करना
git push --all एक command में हर local branch remote पर भेजता है, जो convenient है जब आप locally कई branches में काम कर रहे हों और उन सबको एक साथ publish करना चाहें।
उदाहरण: Pushing All Branches
git push --all
Tags Push करना
Tags default रूप से एक normal push में शामिल नहीं होते -- उन्हें explicitly upload करने के लिए आपको git push --tags (या सिर्फ एक के लिए git push origin <tagname>) चाहिए, क्योंकि tags को regular commit history से अलग treat किया जाता है।
उदाहरण: Pushing Tags
git push --tags
git push origin v1.0
Force Pushing को Safely करना
Force pushing (git push -f) remote की history को आपके local version से overwrite कर देता है, जो चुपचाप एक teammate की पहले से pushed commits destroy कर सकता है। git push --force-with-lease safer alternative है: यह remote को overwrite करने से मना कर देता है अगर उसमें ऐसी commits हों जो आपने नहीं देखीं।
उदाहरण: Force Pushing Safely
git push --force-with-lease
- एक नई branch को plain
git pushसे push करना औरno upstream branchपाना, जबकि पहली push को-u origin <branch>चाहिए। rejected (non-fast-forward)पाना और इसे--forceसे force करना, पहलेgit pullचलाने के बजाय teammates की commits overwrite करते हुए।- यह भूल जाना कि
git pushtags नहीं भेजता, जबकि आपकोgit push --tagsचाहिए।
Chapter Quiz — Complete all 11 topics to unlock
0/11 topics done
Complete these topics first: