I am new to git and hope using it properly.
git init
git add . // added the whole directory
git commit -m "initial stage"
git checkout -b "version1"
git branch
master
* version1
Now i want to add some new files in the directory
cp /path/to/file/admin.php /path/to/git/folder/.
These files should include only on version1 branch but it is also including in the master branch
git add admin.php
git status
On branch version1
Untracked files:
(use "git add <file>..." to include in what will be committed)
admin.php
git checkout master
git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
admin.php
The question is how can i add files only on specific branch??
Thanks
In order to add files in specific branch follow the below instructions :
To create custom branch
git branch branchname
To switch into custom branch
git checkout branchname
To initialize in the custom branch
git init
To add files in the custom branch
git add file name
To commit the changes made in the custom branch
git commit -m "your message"
To make changes in your GitHub repo
git push
Hope you get clear cut idea.
Thank you.
Sometimes when you use
git add fileName
you get this error
The following paths are ignored by one of your .gitignore files: fileName
In order to still add it, go to your .gitignore and comment the line associated with that file adding #,
#fileName
Then you will be able to add, commit, and push.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With