зеркало из https://github.com/dotnet/corefx.git
Страница:
git reference
Страницы
ApiCompat
Build and run tests
Building .NET Core 2.x on FreeBSD
Building .NET Core 3.x on FreeBSD
Checking out the code repository
Contributing
Contributions
Creating a Pull Request
Development environment setup for Linux
Development environment setup for MacOS
Development environment setup for Windows
Enabling New OS
HTTP 2 Implementation Status
Hackathon
Home
Issues
Joining .NET Core team
Links
New contributor Docs
New contributor docs TODO list
Pick issue
Setting up the development environment
UWP Compat
git reference
12
git reference
Patrick Haralabidis редактировал(а) эту страницу 2017-05-23 21:50:12 +10:00
git commands and workflow for beginners
Goal: Keep it simple, no fancy stuff - just easiest way to get things done (and to understand them)
Main text
TODO:
- We need reference table and also basic workflow (1 computer, 2 computers - move work, PR updates / rebase).
- The workflow will naturally create branches for each fix (new git concept)
- Picture with remote, origin and current will be worth thousands words ...
Quick reference
The table below describes the Git flow for creating and updating a pull request.
Task | Git command | Details |
---|---|---|
Fork repository | Fork the repository from the project's github page | See Checking out the code repository |
Clone repository | git clone https://github.com/YOUR-USERNAME/corefx.git |
See Checking out the code repository |
Configure remote repository | git remote add upstream https://github.com/dotnet/corefx.git |
See Checking out the code repository |
Sync repository | git fetch upstream |
Retrieve the latest code from the original fork. |
Sync repository | git checkout master |
Checkout your fork's master branch. |
Sync repository | git merge upstream/master |
Merge the latest code from the original to your fork's master branch. |
Create a branch | git branch < Name of the branch you want to create > |
Creates a new branch on which you will add your code. |
Checkout a branch | git checkout < Name of the branch created above > |
Sets your newly created branch as your current working branch |
Add changes to the queue | git add --all |
Stages all the files you have added and edited for commit |
Commit changes with message | git commit -m < message > |
Commits the changes to your local branch and includes the message as a description |
Push the changes to your remote branch | git push |
Pushes the changes you committed earlier to your local branch to your remote branch |
Raise a pull request | See details | See Raising a pull request |
Ideas / Notes
Very useful git blog posts - Sara Ford's Blog:
Useful starter: Git and GitHub.com
[MS internal] GitHub usage help: http://aka.ms/GitHelp
Logical workflow
Idea: Describe this logical workflow and annotate it with git commands (in a table?)
- Enlist / clone = get sources on your computer
- Work on a fix/feature = create branch
- Tip: What if you forget and realize you have pending files in master, or if you committed to master
- Update (sync) with latest master branch changes
- File operations - edit, delete, rename (how)
- Note: Rename is auto-detected by file content, no 'rename' records in git
- Publish (commit) changes locally
- Note: Don't worry about history too much, it can be cleaned up before final checkin
- ProTip: Don't mix unrelated changes, keep each bug fix / logical work separate - esp. separate larger code cleanup / refactoring / formatting changes (unlikely to introduce regressions) from real functional changes (which may potentially introduce regressions, etc.)
- Backup changes on GitHub
- Share changes between 2 computers (e.g. Laptop & main machine)
- Create PR
- Cleanup your history prior to submitting PR
- //Link to Dos & Don't in PRs - TODO: Is this the right place?
- Update PR to incorporate feedback
- Note: Do not merge master during PR work! Do rebase instead if history is too messy or if there are conflicting changes in master (which is rare!) - if unsure, do it only if you're asked. If you must merge, then do it only after all feedback is incorporated (to avoid restarting the code review from scratch). Note that rebase can be done automatically (by repo maintainers) upon merging your PR -- that should be the 95% case.
karelz's reference
DISCLAIMER: These are my old newbie zero-experience someone-told-me notes, they need to be validated.
Task | Git command | TFS command |
---|---|---|
Enlistment | ||
Enlist | [one-time per repo] Create new repo or your repo fork (GitHub UI)
|
tf workspace /new |
Enlistment info | git remote -v | tf workspace |
Modify | ||
Edit file | Just edit the file
|
tf edit <file> |
Add file | git add <file> | tf add <file> |
Rename file | Just rename file on disk + git add <new_file>, git will automatically detect renames | tf rename <file> |
Delete file | Just delete file on disk + git add <old_file>, git will automatically detect deletes | tf delete <file> |
Undo (local) change | git checkout -- <file>
|
tf undo <file> |
Sync / checkin / history | ||
List pending & local-only changes | git log
|
tf status |
Sync | git pull -r
|
tf get |
Resolve conflicts | tgit resolve | tf resolve |
Diff | tgit diff | tf diff |
Checkin |
|
tf checkin tf submit |
Revert change | TODO | tf revert |
History view | git log UI: gitk |
tf history |
Branches | ||
Create branch / named set of changes ("shelveset") | git checkout -b <branch_name>
|
tf shelve |
Switch between branches ("shelvesets") | git checkout <branch_name> Hint: Use master as branch name |
tf unshelve |
List active branch | git status
|
-- |
List branches |
|
tf shelvesets |
Merge branches | git checkout <target_branch_name> git merge <source_branch_name> |
tf integrate |
Delete branch |
|
tf shelveset /delete |
Other | ||
Create stash / shelveset backup |
|
-- |
Rewriting history | http://sethrobertson.github.io/GitFixUm/fixup.html (incl. dangerous rewrite published history) | -- |