Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • Git Beginners Git Beginners
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Issues 1
    • Issues 1
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Insights
    • Issue
  • Wiki
    • Wiki
  • Activity
  • Create a new issue
  • Issue Boards
Collapse sidebar
  • Computer-ScienceComputer-Science
  • Git BeginnersGit Beginners
  • Wiki
  • Home

Home · Changes

Page history
Git add authored Jul 23, 2018 by Andrew James Collett's avatar Andrew James Collett
Hide whitespace changes
Inline Side-by-side
Home.md
View page @ 8b52cf08
......@@ -142,14 +142,79 @@ Let's get your code from the server to your local machine.
Resolving deltas: 100% (215/215), done.
````
If you have successfully gotten your code onto your local PC, well done!
If you have successfully gotten your code onto your local PC, well done! You should see a new folder within the directory you created with the same name as your project name.
Otherwise, if something went wrong, make a note of the error you encountered and ask a demi for help.
#### Make a local change
Let's create a file in your git folder and see how this change is shown in git.
1. First "cd" into your newly cloned repo. For example following from above:
````bash
$ cd ~/git/netbot/
````
2. Now create a new empty file using the "touch" command.
````
# First we "ls" to list what is in the directory
$ ls
# We see there is nothing. So let's create a file called "fred.txt"
$ touch fred.txt
# Now if we "ls" again we see that fred.txt exists
$ ls
fred.txt
````
3. Now let's ask git what has changed in the repo with "git status":
````
$ git status
On branch master
Your branch is up to date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
fred.txt
nothing added to commit but untracked files present (use "git add" to track)
````
We see that there is a file called "fred.txt" that is not yet in the Index, or in the repo.
4. Let's do as suggested as add the file with `git add fred.txt`.
5. If we `git status` again we see:
````
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: fred.txt
````
Now we see that there are local changes that have not been committed, but are being tracked.
Do step 2 to 4 again with a new file called "java.txt".
Now when we `git status` we see:
````
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: fred
new file: java.txt
````
6. Once you have made all the changes you want for a certain piece of work, you can commit them all together after adding them.
> This is as if you are saying "this is a group of changes that belong together and that I am finished with for now".
We commit these changes with the command `git commit`. Once you issue this command, you will be prompted with a text editor of your choice so that you can add a comment to this set of changes. [see here](#setup). Ask a demi to help you change editors if need be.
In this message you will also see a summary of changes. You should see both "fred.txt" and "java.txt".
#### Sending code back into GitLab
[TODO]
### Understanding the `git` workflow
All commands need to be executed within the directory of your git repo.
......
Clone repository
  • Home