Git Commands

Problem 1:

rejected master -> master (non-fast-forward)

you have a readme file inside git remote repo. but you don’t have that in your local repo.

;;;;; I created a github repository after creating my local git repository so I needed to accept the changes into local before pushing to github. In this case the only change was the readme file created as optional step when creating github repository. ;;;;;



1. git init

2. git pull*username*/*repository*.git master
in my case: git pull master

3. git add .

4. git commit -m "new commit"

5. git remote add origin

6. git push -u origin master

for file check this link with branches

1.create a branch
git branch branch_name all branch
git branch -a or git branch --list
3.switch branch
git checkout branch_name
4.create and checkout at a time
git checkout -b branch_name
5.push only to a branch
git push --set-upstream origin branch_name

3.problem : how to modify the commit messgea

1.very last commit (most recent)
git commit --amend -m "last commit message changed now"
2.other commit messages changes here: -i: interactive HEAD~2 : no of commit
git rebase -i HEAD~2
3.git rebase (–continue | –abort | –skip)
git rebase (--continue | --abort | --skip)

Leave a Comment

Your email address will not be published. Required fields are marked *