demystifying git
TRANSCRIPT
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 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>
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
Contacts
Email: [email protected]
Linkedin: https://br.linkedin.com/pub/pablo-quiroga/2a/36b/b57
Email: [email protected]
Linkedin: https://br.linkedin.com/pub/erickson-alves/7b/a07/257