Editing
Git help
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Just reset from Head === <source> git fetch upstream git checkout master git reset --hard upstream/master git push origin master --force </source> ====Fetching==== Fetching from the remote repository will bring in its branches and their respective commits. These are stored in your local repository unders special branches. <source> git fetch upstream # Grab the upstream remote's branches # remote: Counting objects: 75, done. # remote: Compressing objects: 100% (53/53), done. # remote: Total 62 (delta 27), reused 44 (delta 9) # Unpacking objects: 100% (62/62), done. # From https://github.com/otheruser/repo # * [new branch] master -> upstream/master </source> We now have the upstream's master branch stored in a local branch, upstream/master <source> git branch -va # List all local and remote-tracking branches # * master a422352 My local commit # remotes/origin/HEAD -> origin/master # remotes/origin/master a422352 My local commit # remotes/upstream/master 5fdff0f Some upstream commit </source> ====Merging==== Now that we have fetched the upstream repository, we want to merge its changes into our local branch. This will bring that branch into sync with the upstream, without losing our local changes. <source> git checkout master # Check out our local master branch # Switched to branch 'master' git merge upstream/master # Merge upstream's master into our own # Updating a422352..5fdff0f # Fast-forward # README | 9 ------- # README.md | 7 ++++++ # 2 files changed, 7 insertions(+), 9 deletions(-) # delete mode 100644 README # create mode 100644 README.md </source> If your local branch didn't have any unique commits, git will instead perform a "fast-forward": <source> git merge upstream/master # Updating 34e91da..16c56ad # Fast-forward # README.md | 5 +++-- # 1 file changed, 3 insertions(+), 2 deletions(-) </source>
Summary:
Please note that all contributions to RARForge may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
RARForge:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Home
All Pages
All Files
View Categories
Recent changes
Random page
Edit this menu
Tools
What links here
Related changes
Special pages
Page information