GIT Handson

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

COMMENTING FILES

git add <filename>


git commit -m "<message>"
touch .gitignore
git add .gitignore
git commit -m "<message>"

WORKING REMOTELY
git init
ls
git remote add origin /s/remote.repo
git remote -v
git push origin master
git pull origin master
git clone https://github.com/frescoplaylab/hello-world.git

UNDOING CHANGES
git log --oneline
cat hello.py
vim hello.py
>>print("hello world")
git commit --amend -m "updated print statement"
git status
git diff HEAD
git checkout hello.py
git status
git diff --cached
git reset
git status
git reset --hard
git log --oneline
git show HEAD
git revert HEAD
>>revert "commit to revert"
git revert HEAD...HEAD~3 --no-edit
cat hello.py

MERGE CONFLICTS
git branch
git branch feature1 && git branch feature2
git checkout feature1
vim hello.py
>>print("hello people")
git commit -am "updated file content to hello people"
git checkout master
git merge feature1
git log --all --decorate --oneline
git checkout feature2
git log --all --decorate --oneline
vim hello.py
>>print("keep playing")
git commit -am "updated file content to keep playing"
git checkout master
git merge feature2
git status
cat hello.py
vim hello.py
>>print("keep playing!") //delete everything else
git commit -a
ESC :wq
git branch -d feature1
git branch -d feature2

REBASE
git clone /s/remote-project/chceknumber
cd checkNumber
cat check_number.py
sed -i -e "\$aelse: \n print('{0} is Odd'.format(num))" check_number.py
sed -i '1s/^.*$/#Checks whether number 4 is even or odd/' check_number.py
cat check_number.py
git add check_number.py
git commit -m "<message>"
git fetch origin master
git diff master origin/master
git pull --rebase origin master
vim check_number.py
>>#Read......or odd //delete everything else from <<<<<HEAD to #blue comment
git add check_number.py
git rebase --continue
git log
git push origin master

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy