Difference between revisions of "Git Basics"
Dsteinmark (talk | contribs) |
Dsteinmark (talk | contribs) |
||
| Line 11: | Line 11: | ||
=== Git Vocabulary === | === Git Vocabulary === | ||
| + | |||
| + | '''''Version Control System'' or ''Source Control''''': A system that manages source code for controlling what goes INTO a software version release, and provides a mechanism for making changes and tracking those changes. Your exposure to Source Control is the program to send information to and from the server. | ||
'''Server''': External computer other computers connect to. Runs software to collect and provide information to ''Clients'' (you) | '''Server''': External computer other computers connect to. Runs software to collect and provide information to ''Clients'' (you) | ||
| − | ''' | + | '''Repository''': A database that holds the source code. There is usually a ''local repository'' on your machine, and one ''remote repository'' on the Server. (Usually). |
| − | |||
| − | ''' | ||
| − | ''' | + | '''Clone''': Bring an external project (repository) to your computer to work on it. (Usually only done once, at the beginning.) |
'''Checkout''': Unpack the source code in the local repository, and place it into your Working Folder. | '''Checkout''': Unpack the source code in the local repository, and place it into your Working Folder. | ||
| Line 24: | Line 24: | ||
'''Working Folder''': A directory on your local machine that the code is unpacked into, and where you make your changes. | '''Working Folder''': A directory on your local machine that the code is unpacked into, and where you make your changes. | ||
| − | '''Commit''': Save changes locally (into your local repository) from your Working Folder. | + | '''Commit''': Save changes locally (into your local repository) from your Working Folder. Not yet shared with anyone. |
| − | '''Push''': Send local changes (that have already been commited) to server ( | + | '''Push''': Send local changes (ones that have already been ''commited'') to the server (the shared repository). |
| − | '''Fetch''': Bring server changes into your local repository, ''but not your working folder''. | + | '''Fetch''': Bring server changes into your local repository, ''but not yet into your working folder''. |
| − | '''Pull''': Pull others’ changes that have been pushed to the server, and merge into your working directory. (Does NOT get changes that have only been ''committed'' to the other | + | '''Pull''': Pull others’ changes that have been pushed to the server, and merge into your working directory. (Does NOT get changes that have only been ''committed'' to the other engineer's local repository.) Does a ''fetch'' and a ''merge''. The merge could require you to manage conflicts. |
=== User Setup === | === User Setup === | ||
Revision as of 10:35, 21 June 2019
About Source Control
Git is a great tool for Source Control. Source Control is all about saving, sharing, and managing your source code. It is a significant element of Configuration Management (CM), and Version Control, which deal with managing changes to a Software System (or other systems of information).
For example, did we want to run this upcoming event after bringing in Billy's latest efforts on the Nav system? Did he finish it? Test it fully? Did Joey mess it up thinking it was fixed? CM provides a structured approach to approving changes to the software baseline and pulling them into a release of the software.
Source Control is the first step in a good CM process. It makes sure we save our work, gets it backed up in case we lose our hard drive, and share our work with others. It allows us to roll back to a previous version of working code, identify changes that were made and when, and who made those changes. It can allow us to make sure we have the latest appropriate code from everyone, but we each have to be responsible for getting the latest code.
We have to take this last step of getting latest to make sure our code works with the latest code, and doesn't break anything.
Git Basics
Git Vocabulary
Version Control System or Source Control: A system that manages source code for controlling what goes INTO a software version release, and provides a mechanism for making changes and tracking those changes. Your exposure to Source Control is the program to send information to and from the server.
Server: External computer other computers connect to. Runs software to collect and provide information to Clients (you)
Repository: A database that holds the source code. There is usually a local repository on your machine, and one remote repository on the Server. (Usually).
Clone: Bring an external project (repository) to your computer to work on it. (Usually only done once, at the beginning.)
Checkout: Unpack the source code in the local repository, and place it into your Working Folder.
Working Folder: A directory on your local machine that the code is unpacked into, and where you make your changes.
Commit: Save changes locally (into your local repository) from your Working Folder. Not yet shared with anyone.
Push: Send local changes (ones that have already been commited) to the server (the shared repository).
Fetch: Bring server changes into your local repository, but not yet into your working folder.
Pull: Pull others’ changes that have been pushed to the server, and merge into your working directory. (Does NOT get changes that have only been committed to the other engineer's local repository.) Does a fetch and a merge. The merge could require you to manage conflicts.
User Setup
Git Tutorials
Getting Started with Git. See Chapters 1 and 2.
More Git
Git Basic Commands at Atlassian
Command Line Git
With your pubic key in the gitlab.mort11.org site, you can simply work command line using ssh by default.
1. Clone a repo
git clone git@gitlab.mort11.org:programming/mort_u_robot.git
2. Now see what you have:
jerry.olup@dev0105u16:~/work/IdeaProjects/mort_u_robot$ git branch
* master
>> this tells us that we cloned the repo and by default have the master
3. But what's the span of this repo - what all is in it?
jerry.olup@dev0105u16:~/work/IdeaProjects/mort_u_robot$ git branch -a
* master
remotes/origin/Ganesh
remotes/origin/HEAD -> origin/master
remotes/origin/Kevin
remotes/origin/Matt
remotes/origin/Nick
remotes/origin/master
remotes/origin/vedh
>> "git branch -a lists all local (*master) and remote (all remotes) branches. >> ok now we know what we can draw from, let's switch the HEAD to a branch. >> Kevin just declared victory, let's check his repo out.
4. To now checkout Kevin's repo;
- git checkout -b kevin remotes/origin/Kevin
- git fetch origin
5. Verify this is good: git branch -a
* kevin
master
remotes/origin/Ganesh
remotes/origin/HEAD -> origin/master
remotes/origin/Kevin
remotes/origin/Matt
remotes/origin/Nick
remotes/origin/master
remotes/origin/vedh
>> Now Kevin and master are local, kevin is active and they are all of >> course on the remote server.
"If you use Subversion, you're stupid."
- Linus Torvalds