Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

~$ cd Devel/project
~$ git init
Initialized empty Git repository in /home/bruno/Devel/project/.git/


This will create the git repository. We can confirm this by checking that we have the following files in the directory

...

~$ ls -la
    hello_world.py
    foo.py
    bar.py
    .git


After this we can run a super useful command, that helps us understand the current status of the repo:


~$ git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	bar.py
	foo.py
	hello_world.py

nothing added to commit but untracked files present (use "git add" to track)


So, running this will allow you to find out where are you standing and which files are being tracked.


Tracking files


To track a file we just have to run the add command:


git add hello_world.py


This will stage the files to the so called index. The index is what the repo actually contains, it means that every file in this index is going to be versioned.


When we have files in the index we say that they are staged. At this point running a status will yield the following:


~$ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

	new file:   hello_world.py

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	bar.py
	foo.py


As it can be seen from the ouptut, we have our hello_world.py  file that now is ready to be commited.


Commiting  is the concept of making an impact on the repository history. This is, taking a snapshot of our code.




Artículos Relacionados

Filter by label (Content by label)
showLabelsfalse
max5
spacesDCG
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel in ("code","git","github") and type = "page" and space = "DCG"
labelsgit github code

...