demystifying git

13
Git Desmytifying Git

Upload: pablo-quiroga

Post on 29-Jan-2018

151 views

Category:

Software


0 download

TRANSCRIPT

Git

Desmytifying Git

What is version control??

System that records change to file or set a files over time so that you can recall specific versions later.

GIT

• Distributed Version Control

• Thinks about its data

• Thinks of its data more like snapshots of a miniature of filesystem

• Only need local files and resources to operate.

How to clone a repository?

• To create a copy of a local repository:

git clone /local/repository

• To create a copy of a remote repository:

git clone user@server:/server/repository

How to add and confirm files• To add changes in files:

git add <file> ( for only file)

git add * ( all changed files – untracked)

• To confirm all changes , it is necessary to create a commit:

git commit -m “comments about the commit”

git commit -a -m “comments about the commit” (git add + git commit –m)

How to visualize your commit

• To show all commits in your branch:

git log

How to send changes to a remote repository

• When you have your project at a point that you want to share, you have to push it upstream.

git push origin master

PS: This command works only if you cloned from a server to which you have write access

So, are you talking about sending changes to any remote repo or only a specific one? Sorry, I’m not a Git expert as you are.

Working with branches

• To visualize local branches:

git branch

• To visualize local/remote branches:

git branch –all

Working with branches

• To create a branch:

git checkout –b “new_branch”

• To switch between branches:

git checkout <branch_name>

• To remove a branch:

git checkout –d new_branch

Working with branches

• To update the local repository

git pull

git pull –rebase (update and put your commits in the HEAD)

• To merge all changes between branches: (I didn’t understand this…) don’t known what write

git checkout master

git merge <branch>

Creating Tags

• To create a tag:

git tag <tagversion> <hash>

• To view all tags:

git tag

Fixing errors

• To correct all changes in local files:

git checkout -- <file>

• To remove all changes and return to a stable commit:

git reset – hard

git reset –hard <hash> hash with stable commit

Or

git fetch origin

git reset –hard origin/master