GIT - 4


 how to commit, push & pull from github

=======================================


->login into mumbai EC2 instance

-> create one directory and go inside it

-> git init

-> touch myfile (put some data)

-> git status

-> git add .   (like adding a file in staging area)

-> git commit -m "1st commit from mumbai" (like adding a file in local repo)

-> git status

-> git log

-> git show <commit-id>

-> git remote add origin <centralgit url>

-> git push -u Origin master (enter username and password)

Recently There is having a change in accessing the github. Recently github have started token system for transferring files. Need to login github >> Settings >> Developer settings >> Personal Access Tokens >> Generate new token >> Give the name for the token and select the repo in the scope.... After the token is generated copy the code in the notepad. Therefore while PUSH and PULL to and from ORIGIN you require to put token as an password for github.

Now go to  singapore EC2 instance create One directory and go inside it.

======================================================================

mkdir singapore

cd singapure

--> git init (it will create .git file)

--> git remote add origin <github repo url>

--> git pull origin master   ( pull code from central repository)

--> git log

--> git show <commit-id>

now add some code in the file.

--> git status

--> git add .

--> git commit -m "singapore update 1"

--> git status 

--> git log

--> git push origin master


To ignore some files while committing

======================================

create one hidden file .gitignore and enter file format which you want to ignore

for ex. --> vi .gitignore

               *.css

               *.java

-> git add .gitignore

-> git commit -m "latest update exclude"

-> git status 

create some text, java and css file and add them by running "git add"

for ex. touch file1.txt file2.txt file3.java file4.css


-> ls

-> git status

-> git add

-> git status

-> git commit -m "my text file only" 


git log -1 (to see last commit file)

git log -2 (to see last two commit file)

git log --oneline  (to see all commit files in one line)

git log --grep "ignore" (if you forgot commit id so you can grep the name)


Comments

Popular posts from this blog

GIT - 3

Docker - 6

GIT - 1