https___training.github.com_git-guides_git-pull_.xml
https___training.github.com_downloads_ne_github-git-cheat-sheet__1.xml
1.1 2.1 2.2 3.1 4.1 5.1 6.1 7.1 8.1 9.1 9.2 10.1 11.1 11.2 12.1 13.1 14.1 15.1 16.1 17.1 17.2 18.1 18.2 19.1 20.1 21.1 22.1 23.1 24.1 24.2 24.3 24.4 24.5 25.1 25.2 26.1 27.1 27.2 28.1 29.1 30.1 31.1 32.1 33.1 34.1 35.1 35.2 36.1 37.1 38.1 39.1 41.1 43.1 45.1 46.1 46.2 47.1 49.1 50.1 51.1 52.1 53.1 54.1 55.1 56.1 56.2 56.3 57.1 58.1 59.1 60.1 60.2 61.1 61.2 62.1 63.1 63.2 63.3 63.4 64.1 65.1 66.1 66.2 67.1 68.1 69.1 70.1 71.1 72.1 73.1 73.2 73.3 73.4 74.1 75.1 75.2 75.3 76.1 77.1 78.1 79.1 80.1 81.1 82.1 83.1 84.1 84.2 85.1 85.2 85.3 85.4 86.1 87.1 87.2 88.1 89.1 90.1 91.1 91.2 92.1 92.2 93.1 95.1 96.1 97.1 98.1 100.1 101.1 102.1 103.1 104.1 105.1 106.1 106.2 106.3 107.1 108.1 109.1 110.1 111.1 112.1 114.1 116.1 118.1 118.2 119.1 120.1 121.1 122.1 124.1 126.1 128.1 129.1
Git Pull git pull updates your current local working branch and all of the remote tracking branches. It’s a good idea to run git pull regularly on the branches you are working on locally. Without git pull, (or the effect of it,) your local branch wouldn’t have any of the updates that are present on the remote. What Does git pull Do? git pull git pull is one of the 4 remote operations within Git. Without running git pull, your local repository will never be updated with changes from the remote. git pull should be used every day you interact with a repository with a remote, at the minimum. That’s why git pull is one of the most used Git commands. git pull and git fetch git pull, a combination of git fetch + git merge, updates some parts of your local repository with changes from the remote repository. To understand what is and isn’t affected by git pull, you need to first understand the concept of remote tracking branches. When you clone a repository, you clone one working branch, main, and all of the remote tracking branches. git fetch updates the remote tracking branches. git merge will update your current branch with any new commits on the remote tracking branch. git pull is the most common way to update your repository. However, you may want to use git fetch instead. One reason to do this may be that you expect conflicts. Conflicts can occur in this way if you have new local commits and new commits on the remote. Just like a merge conflict that would happen between two different branches, these two different lines of history could contain changes to the same parts of the same file. If you first operate git fetch, the merge won’t be initiated, and you won’t be prompted to solve the conflict. This gives you the flexibility to resolve the conflict later without the need for network connectivity. Another reason you may want to run git fetch is to update to all remote tracking branches before losing network connectivity. If you run git fetch, and then later try to run git pull without any network connectivity, the git fetch portion of the git pull operation will fail. If you do use git fetch instead of git pull, make sure you remember to git merge. Merging the remote tracking branch into your own branch ensures you will be working with any updates or changes. How to Use git pull Common usages and options for git pull git pull: Update your local working branch with commits from the remote, and update all remote tracking branches. git pull --rebase: Update your local working branch with commits from the remote, but rewrite history so any local commits occur after all new commits coming from the remote, avoiding a merge commit. git pull --force: This option allows you to force a fetch of a specific remote tracking branch when using the option that would otherwise not be fetched due to conflicts. To force Git to overwrite your current branch to match the remote tracking branch, read below about using git reset. git pull --all: Fetch all remotes – this is handy if you are working on a fork or in another use case with multiple remotes. You can see all of the many options with git pull in git-scm’s documentation. Examples of git pull Working on a Branch If you’re already working on a branch, it is a good idea to run git pull before starting work and introducing new commits. Even if you take a small break from development, there’s a chance that one of your collaborators has made changes to your branch. This change could even come from updating your branch with new changes from main. It is always a good idea to run git status – especially before git pull. Changes that are not committed can be overwritten during a git pull. Or, they can block the git merge portion of the git pull from executing. If you have files that are changed, but not committed, and the changes on the remote also change those same parts of the same file, Git must make a choice. Since they are not committed changes, there is no possibility for a merge conflict. Git will either overwrite the changes in your working or staging directories, or the merge will not complete, and you will not be able to include any of the updates from the remote. If this happens, use git status to identify what changes are causing the problem. Either delete or commit those changes, then git pull or git merge again. Keep main up to date Keeping the main branch up to date is generally a good idea. For example, let’s say you have cloned a repository. After you clone, someone merges a branch into main. Then, you’d like to create a new branch to do some work. If you create your branch off of main before operating git pull, your branch will not have the most recent changes. You could accidentally introduce a conflict or duplicate changes. By running git pull before you create a branch, you can be sure that you will be working with the most recent information. Undo A git pull To effectively “undo” a git pull, you cannot undo the git fetch – but you can undo the git merge that changed your local working branch. To do this, you will need to git reset to the commit you made before you merged. You can find this commit by searching the git reflog. The reflog is a log of every place that HEAD has pointed – every place that you have ever been checked out to. This reflog is only kept for 30 to 90 days, depending on the commit, and is only stored locally. (The reflog is a great reason not to delete a repository if you think you’ve made a mistake!) Run git reflog and search for the commit that you would like to return to. Then, run git reset --hard   to reset HEAD and your current branch to the SHA of the commit from before the merge. Force git pull to Overwrite Local Files If you have made commits locally that you regret, you may want your local branch to match the remote branch without saving any of your work. This can be done using git reset. First, make sure you have the most recent copy of that remote tracking branch by fetching. git fetch git fetch origin main Then, use git reset --hard to move the HEAD pointer and the current branch pointer to the most recent commit as it exists on that remote tracking branch. git reset --hard  / git reset --hard origin/main _Note: You can find the remotes with git remote -v, and see all available remote tracking branches with git branch --all. git pull with Rebase If there have been new commits on both your local branch and the remote branch, a merge commit will be created when you git pull. This recursive merge is the default merge style when there are two splits in history being brought together. But, you may want history on a branch to be only one line. You can update your local working branch with commits from the remote, but rewrite history so any local commits occur after all new commits coming from the remote, avoiding a merge commit. This is done with git pull --rebase. Using git pull --rebase does not affect the integrity of the changes or the commits, but it does affect how history looks in the commit parent/child relationship. Related Terms git clone [url]: Clone (download) a repository that already exists on GitHub, including all of the files, branches, and commits. git status: Always a good idea, this command shows you what branch you’re on, what files are in the working or staging directory, and any other important information. git branch: This shows the existing branches in your local repository. You can also use git branch [banch-name]to create a branch from your current location, or git branch --allto see all branches, both the local ones on your machine, and the remote tracking branches stored from the last git pullor git fetchfrom the remote. git push: Uploads all local branch commits to the remote. git log: Browse and inspect the evolution of project files. git remote -v: Show the associated remote repositories and their stored name, like origin.
1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 11.1 12.1 13.1 14.1 15.1 16.1 17.1 18.1 19.1 20.1 21.1 22.1 23.1 24.1 25.1 26.1 27.1 28.1 29.1 30.1 31.1 32.1 33.1 34.1 35.1 36.1 37.1 38.1 39.1 40.1 41.1 42.1 43.1 44.1 45.1 46.1 47.1 48.1 49.1 50.1 51.1 52.1 53.1 54.1 55.1 56.1 57.1 58.1 59.1 60.1 61.1 62.1 63.1 64.1 65.1 66.1 67.1 68.1 69.1 70.1 71.1 72.1 73.1 74.1 75.1 76.1 77.1 78.1 79.1 81.1 82.1
इन्स्टल गर्नुहोस GitHub डेस्कटप Git सबै प्लेटफर्मका लागि Configure गर्नुहोस सबै लोकल रेपोजिटोरिहरुको लागि प्रयोगकर्ताको जानकारी configure गर्नुहोस् $ git config --global user.name "[name]" यसले तपाइले commit गर्दा संलग्न गर्न चाहानु भएको नाम सेट गर्दछ $ git config --global user.email "[email address]" यसले तपाइले commit गर्दा संलग्न गर्न चाहानु भएको इमेल सेट गर्दछ $ git config --global color.ui auto यसले कमाण्ड लाइन आउटपुटको रङकरण गर्दछ Branches Branches हरु Git संग काम गर्नलाई महत्त्वपूर्ण हुन्छन्। अहिले “checked out” branch मा तपाइले गरेको commit हरु राखिनेछ। Branch हेर्नकालागि git status को प्रयोग गर्न सक्नुहुनेछ। $ git branch [branch-name] यसले नया branch बनाउनेछ $ git switch -c [branch-name] यसले तपाइको working directory लाई तपाइले चयन गर्नुभएको branch मा परिवर्तन गर्नेछ $ git merge [branch] यसले तपाइले चयन गर्नुभएको branch को history ल ाई वर्तमान branch मा मिश्रित गराउनेछ। यो प्रायजसो pull request हरुमा गरिन्छ, तर यो पनि एउटा महत्वपुर्ण कार्य हो। $ git branch -d [branch-name] यसले तपाइले चयन गर्नुभएको branch मेटाउनेछ Repository बनाउनुहोस नया repository आफ्नो कम्प्युटरमा बनाउन सकिन्छ अथवा कसैले बनाएको repository क्लोन गर्न सकिन्छ। यदी तपाइले आफ्नो कम्प्युटरमा repository बनाउनु भयो भने उक्त repository लाई पछि GitHub मा push गर्नुपर्ने हुन्छ। $ git init यदी तपाइले काम गर्दै गरेको directory मा git init कमाण्ड रन गर्नुभयो भने उक्त directory लाई Git repository मा परिणत गर्नेछ। git init कमाण्ड प्रयोग गरेपछि, उक्त directory लाई खाली Git repository संग लिंक गर्न निम्न कमाण्ड प्रयोग गर्नुहोस् : $ git remote add origin [url] यसले तपाइको कम्प्युटर मा भएको लोकल repository लाई remote repository संग लिंक गर्नेछ। URL ले GitHub मा भएको repository लाई औंलााउनेछ। $ git clone [url] यसले URL को, repository लाई डाउनलोड अथवा क्लोन गर्नेछ। क्लोनमा सबै फाइल, branch अनि commit हरु संलग्न गरिनेछ। .gitignore फाइल कहिले कहिँ कुनै फाइलहरु Git ले ट्रयाक न गर्नु राम्रो विचार हुन सक्छ। यो प्रक्रिया एउटा फाइल मा गरिन्छ जसको नाम .gitignore हो। यसका लागि तपाइले टेम्पलेट github.com/github/gitignore मा भेटाउन सक्नुहुनेछ। परिवर्तनहरु syncornization गर्नुहोस तपाइको कम्प्युटर मा रहेको लोकल repository लाई github.com को remote repository संग synchronize गर्नुहोस $ git fetch यसले रिमोट ट्रयाकइंग branch को सबै डाउनलोड गर्नेछ $ git merge यसले रिमोट ट्रयाकइंग branch लाई वर्तमान लोकल संग मिश्रित गर्नेछ $ git push यसले लोकल branch को सबै commit लाई GitHub मा अपलोड गर्नेछ $ git pull यसले तपाइको वर्तमान working repository लाई तेही अनुरुपको रिमोट branch को परिवर्तनहरु संग अपडेट गर्नेछ l git pull, git fetch, र git merge को संयोजन हो। Make changes प्रोजेक्ट फाइलको एभोलुशन ब्राउज र इन्स्पेक्ट गर्नुहोस् $ git log यसले वर्तमान branchको भर्सन हिस्ट्री लिस्ट गर्नेछ $ git log --follow [file] यसले फाइल को भर्जन हिस्ट्री लिस्ट गर्नेछ, रिनेम भाएक (एउटा फाइलको लागि मात्रै काम गर्नेछ) $ git diff [first-branch]...[second-branch] यसले दुइ branch बिच भिन्नता देखाउनेछ $ git show [commit] यसले निर्धारित commit र मेटाडाटा को परिवर्तन हरु देखाउनेछ $ git add [file] यसले भर्जनिंग को लागि काम गरिराखेको फाइल को स्न्यापसट लिनेछ $ git commit -m "[descriptive message]" यसले कामगरिराखेको फाइल को स्न्यापसट commits दोहोराउनुहोस यसले गल्ति र क्राफ्ट रिप्लेस्मेंट हिस्ट्री मेटाउछ $ git reset [commit] यसले परिवर्तनहरुलाई लोकल्ली प्रिजर्व गरेर, [commit] पछाडिको commits हरु मेटाउछ $ git reset --hard [commit] यसले सबै history मेटाएर निर्धारित commit मा लाग्नेछ साबधान! हिस्ट्री परिवर्तन गर्दा धेरै साइड इफ्फेक्ट हुनसक्छन l यदी तपाईलाई GitHub मा भएको हिस्ट्री परिवर्तन गर्न खोज्दैहुनुन्छ भने साबधानी अप्प्नाउनु होला l की समस्या भए github.community मा जान सक्नुहुनेछ अथवा सुप्पोर्ट टिमलाई सम्पर्क गर्नसक्नुहुने छ। Glossary - Git: एउटा ओपन सोर्स, वितरित भर्जन कन्ट्रोल सिस्टम - GitHub: Git repositories होस्ट गर्ने र अरु संग collaborate गर्ने प्लेटफर्म - commit: Repository को सबै परिवर्तन हरु को स्न्यापसट - branch: Commit लाई पोइन्ट गर्ने पोइन्टर - clone: सबै commit र branches भएको Remote repositoryको लोकल भर्जन - remote: सबै योगदानकर्ता ले योगदान आदान प्रदान गर्न मिल्ने common GitHub repository - fork: अरु कसैको GitHub repository को कपि - pull request: repository मा परिवर्तनहरु सल्लाह गर्ने स्थान HEAD: वर्तमान working directory लाई जनाउने पोइंटर, HEAD पोइंटर लाई git switchको प्रयोग गरेर विभिन्न branches, tags र commits लाई पोइन्ट गर्न सकिन्छ