Using Git Example: Difference between revisions
From Genome Analysis Wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
| Line 59: | Line 59: | ||
|} | |} | ||
== Add | == Add Files to the Repository == | ||
This will create a couple of files in ~/code/learnGit/learningGit/. | |||
The files will not show up in ~/code/learnGit/learningGit2/. | |||
{| border="1" | {| border="1" | ||
|valign="top"| | |valign="top"| | ||
=== Create the New Files === | === Create the New Files === | ||
These steps create README.txt and README1.txt in ~/code/learnGit/. | These steps create README.txt and README1.txt in ~/code/learnGit/learningGit/. | ||
# Move to the ~/code/learnGit/learningGit | |||
# Look at the current status to see nothing. | |||
# Create README.txt | # Create README.txt | ||
# Create README1.txt | # Create README1.txt | ||
# Look at the git status to see 2 untracked files. | # Look at the git status to see 2 untracked files. | ||
# Move to the learningGit2 directory | |||
# Check that the files are not there | |||
# Check the status in learningGit2 | |||
cd ~/code/learnGit/learningGit | |||
git status | |||
echo This repo is for Learning Git. > README.txt | echo This repo is for Learning Git. > README.txt | ||
echo Another file in the repository > README1.txt | echo Another file in the repository > README1.txt | ||
| Line 101: | Line 88: | ||
|valign="top"| | |valign="top"| | ||
===Stage the files=== | ===Stage the files=== | ||
This step stages the addition of README.txt and README1.txt | This step stages the addition of README.txt and README1.txt in ~/code/learnGit/learningGit/. | ||
# Move back to the learningGit directory | |||
# Stage the files | # Stage the files | ||
# Look at the git status to see 2 staged files. | # Look at the git status to see 2 staged files. | ||
# Move back to the learningGit2 directory | |||
# Try to pull files | |||
# Check the contents of learningGit2 to verify the files are NOT there. | |||
cd ../learningGit | |||
git add . | git add . | ||
git status | git status | ||
cd ../learningGit2 | |||
git pull | |||
ls | |||
Note: the files are staged, but not yet stored in the repository. | Note: the files are staged, but not yet stored in the ~/code/learnGit/learningGit repository. | ||
|[[Image:GitStageFiles.png]] | |[[Image:GitStageFiles.png]] | ||
|- | |- | ||
| Line 115: | Line 110: | ||
This step stores README.txt and README1.txt in the local repository. | This step stores README.txt and README1.txt in the local repository. | ||
# Move back to the learningGit directory | |||
# Commit the files | # Commit the files | ||
# Look at the git status to see no uncommitted changes. | # Look at the git status to see no uncommitted changes. | ||
# Move back to the learningGit2 directory | |||
# Try to pull files | |||
# Check the contents of learningGit2 to verify the files are NOT there. | |||
cd ../learningGit | |||
git commit -m "Add the first files" | git commit -m "Add the first files" | ||
git status | git status | ||
cd ../learningGit2 | |||
git pull | |||
ls | |||
Note: the files are stored in the | Note: the files are stored in the ~/code/learnGit/learningGit repository, but are not yet in the bare repository. | ||
|[[Image:GitCommit.png]] | |[[Image:GitCommit.png]] | ||
|- | |- | ||
| Line 127: | Line 130: | ||
This step pushes the files to the bare repository. | This step pushes the files to the bare repository. | ||
# Move back to the learningGit directory | |||
# Push the files without specifying the remote or branch (fails) | # Push the files without specifying the remote or branch (fails) | ||
# Push the files specifying the remote and the branch (succeeds) | # Push the files specifying the remote and the branch (succeeds) | ||
# Look at the git status to see no uncommitted changes. | |||
# Move back to the learningGit2 directory | |||
# Try to pull files | |||
# Check the contents of learningGit2 to verify the files are there. | |||
cd ../learningGit | |||
git push | git push | ||
git push origin master | git push origin master | ||
git status | |||
cd ../learningGit2 | |||
git pull | |||
ls | |||
|[[Image:GitPush.png]] | |[[Image:GitPush.png]] | ||
|} | |} | ||
Revision as of 09:09, 8 July 2011
Create new Bare Repository
Create Working Repositories
For this example, we are going to create 2 working repositories.
This is so you can see how changes don't affect the other repositories unless pushes & pulls are done.
Create a Working RepositoryThese steps will create a new working repository called learningGit in ~/code/learnGit/ that is a clone of ~/code/learnGit/bareRepo/learningGit.
cd ~/code/learnGit git clone ~/code/learnGit/bareRepo/learningGit cd learningGit ls -a |
|
Create a Second Working RepositoryThese steps will create a second working repository called learningGit2 in ~/code/learnGit/ that is a clone of ~/code/learnGit/bareRepo/learningGit.
cd ~/code/learnGit git clone ~/code/learnGit/bareRepo/learningGit learningGit2 cd learningGit2 ls -a |
Add Files to the Repository
This will create a couple of files in ~/code/learnGit/learningGit/.
The files will not show up in ~/code/learnGit/learningGit2/.






