Thursday, 29 August 2019

Ignoring Unwanted files and folders in Git by Raj Gupta


Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ ls -al
total 19
drwxr-xr-x 1 Administrator 197121    0 Aug 29 08:35 ./
drwxr-xr-x 1 Administrator 197121    0 Aug 29 07:52 ../
drwxr-xr-x 1 Administrator 197121    0 Aug 29 08:35 .git/
-rw-r--r-- 1 Administrator 197121  133 Aug 29 07:52 Dockerfile
-rw-r--r-- 1 Administrator 197121 5969 Aug 29 07:52 pom.xml
-rw-r--r-- 1 Administrator 197121   38 Aug 29 07:52 README.md
drwxr-xr-x 1 Administrator 197121    0 Aug 29 07:52 server/
-rw-r--r-- 1 Administrator 197121   29 Aug 29 08:35 start2.txt
drwxr-xr-x 1 Administrator 197121    0 Aug 29 07:52 webapp/

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ vi ramu.yyy

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ ls
Dockerfile  pom.xml  ramu.yyy  README.md  server/  start2.txt  webapp/

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 3 commits.
  (use "git push" to publish your local commits)

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        ramu.yyy

nothing added to commit but untracked files present (use "git add" to track)

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ vi .gitignore

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ cat .gitignore
*.yyy

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 3 commits.
  (use "git push" to publish your local commits)

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .gitignore

nothing added to commit but untracked files present (use "git add" to track)

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git add .gitignore

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 3 commits.
  (use "git push" to publish your local commits)

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   .gitignore


Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git commit .gitignore -m "ignore"
[master 8637d7a] ignore
 1 file changed, 1 insertion(+)
 create mode 100644 .gitignore

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 4 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$

No comments:

Post a Comment