GIT Control

GIT Control GIT Control - Start

2017-08-29 46K 46 0 0

GIT Control - Description

Basics of GIT for developers and system administrators. Jennifer Watson. System Engineer. University of Maine . System. NECWIC 2017. Reasons to USE GIT. Working on complex code project. Working on code from more than one computer. ID: 583422 Download Presentation

Download Presentation

GIT Control




Download Presentation - The PPT/PDF document "GIT Control" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.



Presentations text content in GIT Control

Slide1

GIT Control

Basics of GIT for developers and system administrators

Jennifer Watson

System Engineer

University of Maine

System

NECWIC 2017

Slide2

Reasons to USE GIT

Working on complex code project

Working on code from more than one computer

Collaborating with others

on code or text file

Maintain version control on code or file

Be able to see when code or configuration files have changed

and be able to note/read why it was changed

Want to compare or merge different versions

Be able to roll back quickly to last known working version after changes break something

Distributed copies of code or file provide back up in case of lose

Slide3

Installing GIT

Installed by default on modern *nix Operating systems, but may still want to grab latest versionhttps://git-scm.com/downloadsMay also consider GUI clientSourceTree (free, Mac and Win) https://www.sourcetreeapp.com/

Slide4

Configuring GIT

From a command line:

git

config

global

user.name

FirstName

LastName

git

config

global

user.email

yourname@maine.edu

git

config

global

color.ui

“auto”

Mac/

linux

git

config

global

core.editor

nano

w”

Windows

git

config

global

core.editor

“’c:/program files (x86)/Notepad++/notepad++.exe’

multiInst

notabbar

nosession

noPlugin

git

config

--list

Slide5

Create a GIT Repository

From the command line, Make and/or navigate to the directory/folder for

Git

to track

Type the command:

git

init

Slide6

GIT COMMANDS

git

status

git

add <file>

git

add .

git

commit

m “

message

git

log --graph

git

diff

git

diff

staged

git

diff HEAD~1 (can substitute 3 version back you want to compare to current version)

git

diff

CommitIHash

Slide7

GIT commands (continued)

git checkout <branch>switch branchesgit checkout HEAD~1 Reverts to previously committed versioncan be used to undelete a filegit reset HEAD <file>Un-stage filegit reset --hard Everything reverted to last commit

!

Be careful with

reset commands

Slide8

a

ka

Staging

Notice the difference between pull and fetch

Slide9

Working with remote repositories

git

clone <

url

>

git

remote add

<remote> <

url

for repository on

gitLab

or

ssh

link>

git

remote

v

Lists existing remotes

git

fetch <remote> <branch>

Recommend using

fetch

instead of

pull

git

push <remote> <branch>

Slide10

Using REMOTES with ssh

cd ~/.

ssh

ssh-keygen

Open the

rsa.pub

file

created

and copy the contents to your remote repository

Begins with

ssh-rsa

and ends with

username@computername

Slide11

Typical Day with Git

Really Good Daygit fetch <remote> <feature branch>Or git pullWork on codegit statusgit add <file(s) I worked on/edited>git commit –m “<message about what I fixed with maybe a tag for ticket closure or release>”git fetch <remote> <feature branch>merge/Resolve differences git push <remote> <feature branch>Submit a Pull Request for approval

Not so Good Day

git

fetch <remote> <feature branch>

Work on code

Get stuck

git

status

git

add <file(s) I worked on/edited>

git

checkout

b <remote> <

nameForNewBranch

>

git

commit

m “[WIP]<what I was trying to fix and my attempted approach>”

Pull Request (aka Merge Request) to teammate

Receive feedback/help/resolution --> unstuck

Continue on with Really Good Day workflow

Slide12

Working with a Team in GIT vs Alone

TEAMMake sure editor/IDE configured for team agreed upon line lengthsCommit often, but generally push working code that fixes an issue or completes featureMake sure to fetch prior to push to then merge in any changes that have occurred on the remotePull requests allow you to ask someone to review your code for approval, but don’t forget it can also be helpful for asking for help if you get stuckMore prescribed branching

ALONECommit often and feel free to push every time as it creates a backup of your codeOnly need to fetch and merge changes if you had pushed work from another computer to the remoteThis is when to try out and learn about rebasing (only on private branches)

!

Do NOT rebase on public branch

Slide13

Git Branching

Source: https://

leanpub.com

/

git

-flow/read

Slide14

GIT TIPS

Create .

gitignore

file in at root of

git

respository

List files to ignore

Can use *.

file-extension

can still force add exceptions using

git

add

f

file

Great for excluding files your IDE may add to your

Git

tracked folder on your local computer

Create hidden file in new folders you create with the following command:

touch .

gitkeep

git

cannot track an empty folder, so this is basically a placeholder

file

Slide15

Git for system administrators

git

init

on the folders with important configurations

Know if someone else changed them by using

git

status

And what they changed with

git

log and

git

diff

Explain why you changed them with

git

commit

m “<reason>” so other admins will know

Quickly bring back an earlier working version of the

file

with

git

checkout -- <file

>

Back up those key configurations easily by

git

push <remote> <branch>

Note:

git

keeps track of changes NOT multiple copies of the file,

so

it does not take up a lot of space

Slide16

Learning resources

Code

Academy https

://

www.codecademy.com

/learn/learn-

git

https://

www.tutorialspoint.com

/

git

/

More on How to Use in a Team https

://

www.sitepoint.com

/getting-started-

git

-team-environment

/

https://

git-scm.com

/book/

en

/v2/

Git

-Basics-Undoing-Things

https://

www.atlassian.com

/

git

/tutorials/merging-vs-rebasing


About DocSlides
DocSlides allows users to easily upload and share presentations, PDF documents, and images.Share your documents with the world , watch,share and upload any time you want. How can you benefit from using DocSlides? DocSlides consists documents from individuals and organizations on topics ranging from technology and business to travel, health, and education. Find and search for what interests you, and learn from people and more. You can also download DocSlides to read or reference later.